Skip to content

Commit

Permalink
store Bind laddr in netip.AddrPort
Browse files Browse the repository at this point in the history
  • Loading branch information
scottfeldman authored and deadprogram committed Dec 6, 2023
1 parent 7a7235f commit d6ae0b0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions espat/espat.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ type Config struct {
type socket struct {
inUse bool
protocol int
lip netip.Addr
lport uint16
laddr netip.AddrPort
}

type Device struct {
Expand Down Expand Up @@ -180,16 +179,15 @@ func (d *Device) Socket(domain int, stype int, protocol int) (int, error) {
}

func (d *Device) Bind(sockfd int, ip netip.AddrPort) error {
d.socket.lip = ip.Addr()
d.socket.lport = ip.Port()
d.socket.laddr = ip
return nil
}

func (d *Device) Connect(sockfd int, host string, ip netip.AddrPort) error {
var err error
var addr = ip.Addr().String()
var rport = strconv.Itoa(int(ip.Port()))
var lport = strconv.Itoa(int(d.socket.lport))
var lport = strconv.Itoa(int(d.socket.laddr.Port()))

switch d.socket.protocol {
case netdev.IPPROTO_TCP:
Expand Down

0 comments on commit d6ae0b0

Please sign in to comment.