Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirectTCPIPHandler func use payload origin addr and port #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

DirectTCPIPHandler func use payload origin addr and port #140

wants to merge 1 commit into from

Conversation

eudore
Copy link

@eudore eudore commented Sep 24, 2020

The DirectTCPIPHandler function establishes a new connection using the net.TCPAddr function so that the address and port of Origin can be set.

func DirectTCPIPHandler(srv *Server, conn *gossh.ServerConn, newChan gossh.NewChannel, ctx Context) {
	d := localForwardChannelData{}
	...
	laddr := &net.TCPAddr{
		IP:   net.ParseIP(d.OriginAddr),
		Port: int(d.OriginPort),
	}
	raddr := &net.TCPAddr{
		IP:   net.ParseIP(d.DestAddr),
		Port: int(d.DestPort),
	}
	dconn, err := net.DialTCP("tcp", laddr, raddr)
	...
}

IP: net.ParseIP(d.DestAddr),
Port: int(d.DestPort),
}
dconn, err := net.DialTCP("tcp", laddr, raddr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would be a worthwhile change (though I'm not 100% sure I understand it), but I'd like for it to be done without dropping ctx from the dial call.

I believe this can be done by setting dialer. LocalAddr to the laddr and using the previous method of creating the raddr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants