Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Use net.TCPAddr rather string
Browse files Browse the repository at this point in the history
  • Loading branch information
bzEq committed Apr 26, 2024
1 parent 10b5bea commit 19d50e0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion proxy/intrinsic/acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (self *Acceptor) handshake(c net.Conn) (p core.Port, addr net.Addr, err err
if err != nil {
return
}
addr = &req.TCPAddr
addr = &req.Addr
default:
err = fmt.Errorf("Unsupported function: %d", i.Func)
}
Expand Down
6 changes: 5 additions & 1 deletion proxy/intrinsic/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func (self *ClientContext) dialUDP(network, addr string) (net.Conn, error) {
}

func (self *ClientContext) dialTCP(network, addr string) (net.Conn, error) {
raddr, err := net.ResolveTCPAddr(network, addr)
if err != nil {
return nil, err
}
local := core.MakePipe()
go func() {
defer local[1].Close()
Expand All @@ -109,7 +113,7 @@ func (self *ClientContext) dialTCP(network, addr string) (net.Conn, error) {
i := Intrinsic{Func: RELAY_TCP}
{
data := &bytes.Buffer{}
req := TCPRequest{Addr: addr}
req := TCPRequest{Addr: *raddr}
enc := gob.NewEncoder(data)
if err := enc.Encode(&req); err != nil {
log.Println(err)
Expand Down
2 changes: 1 addition & 1 deletion proxy/intrinsic/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (self *Dialer) handshake(c net.Conn, addr net.Addr) (p core.Port, err error
i := Intrinsic{Func: RELAY_TCP}
{
data := &bytes.Buffer{}
req := TCPRequest{TCPAddr: *addr.(*net.TCPAddr)}
req := TCPRequest{Addr: *addr.(*net.TCPAddr)}
enc := gob.NewEncoder(data)
err = enc.Encode(&req)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions proxy/intrinsic/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const (
)

type TCPRequest struct {
Addr string
TCPAddr net.TCPAddr
Addr net.TCPAddr
}

type UDPMessage struct {
Expand Down Expand Up @@ -129,7 +128,7 @@ func (self *Server) Run() {
log.Println(err)
return
}
if err := self.relayTCP(req.Addr); err != nil {
if err := self.relayTCP(req.Addr.String()); err != nil {
log.Println(err)
return
}
Expand Down

0 comments on commit 19d50e0

Please sign in to comment.