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

Make connection using specific ip #139

Open
kofany opened this issue Oct 5, 2022 · 7 comments
Open

Make connection using specific ip #139

kofany opened this issue Oct 5, 2022 · 7 comments

Comments

@kofany
Copy link

kofany commented Oct 5, 2022

Can we bind specifc ip to irc connection?

@thoj
Copy link
Owner

thoj commented Oct 5, 2022

Not in the current code.
After this line:

dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout})

Add
dialer.LocalAddress := "192.168.0.2"

Pr Welcome.

@kofany
Copy link
Author

kofany commented Oct 5, 2022

Hi again, im getting an error:
dialer.LocalAddress undefined (type proxy.Dialer has no field or method LocalAddress)

@kofany
Copy link
Author

kofany commented Oct 5, 2022

the code is:

    dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout})
dialer.LocalAddress = "127.0.0.1"
irc.socket, err = dialer.Dial("tcp", irc.Server)

@thoj
Copy link
Owner

thoj commented Oct 5, 2022

dialer := proxy.FromEnvironmentUsing(&net.Dialer{Timeout: irc.Timeout, LocalAddress: "127.0.0.1"})
irc.socket, err = dialer.Dial("tcp", irc.Server)

@kofany
Copy link
Author

kofany commented Oct 5, 2022

Sorry but also error irc.go:466:73: unknown field 'LocalAddress' in struct literal of type net.Dialer

@thoj
Copy link
Owner

thoj commented Oct 5, 2022

try LocalAddr

If that doesn't work I don't know. Check the go documentation.

@kofany
Copy link
Author

kofany commented Nov 3, 2022

Hi i manage to get it work with code:
(all changes You can see on my GitHub (In fork)

dialer := proxy.FromEnvironmentUsing(&net.Dialer{ LocalAddr: &net.TCPAddr{
        IP:   net.ParseIP(irc.myhost),
        Port: 0,
    	},Timeout: irc.Timeout})
	
//where myhost is passed here:
func IRC(nick, user string, myhost string) *Connection {
	// catch invalid values

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

No branches or pull requests

2 participants