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

ubuntu20 BUG~ server_response函数 #15

Open
golangboy opened this issue Sep 23, 2021 · 5 comments
Open

ubuntu20 BUG~ server_response函数 #15

golangboy opened this issue Sep 23, 2021 · 5 comments

Comments

@golangboy
Copy link

golangboy commented Sep 23, 2021

cat /proc/version

Linux version 5.11.0-34-generic (buildd@lgw01-amd64-001) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021

servers_response_linux.go 里的 server_response 函数 发生问题,即 无法向目标地址建立连接,我调试了一下,问题就是在

	dialer := net.Dialer{
		LocalAddr: local_tcpaddr,
		Control: func(network, address string, c syscall.RawConn) error {
			return c.Control(func(fd uintptr) {
				// NOTE: Run with root or use setcap to allow interface binding
				// sudo setcap cap_net_raw=eip ./go-dispatch-proxy
				if err := syscall.BindToDevice(int(fd), load_balancer.iface); err != nil {
					log.Println("[WARN] Couldn't bind to interface", load_balancer.iface)
				}
			})
		},
	}

	remote_conn, err := dialer.Dial("tcp4", remote_address)

作者的意图大概是用linux的调用绑定到具体的网卡上 ,但其实只要绑定本地地址到对应网卡上的IP上就达到了绑定socket到具体网卡上的效果了,即把servers_response.go里的server_response全部照搬到servers_response_linux.goserver_response 函数就可以了,能达到一样的效果,我按这样修改了达到了期待的效果。

@SirSAC
Copy link

SirSAC commented Sep 23, 2021

Hi, try https://github.com/SirSAC/DisPro

@golangboy
Copy link
Author

Hi, try https://github.com/SirSAC/DisPro

It looks really good.I will try it now.

@SirSAC
Copy link

SirSAC commented Sep 24, 2021

Hi, try https://github.com/SirSAC/DisPro

It looks really good.I will try it now.

its working fine for u?

@extremecoders-re
Copy link
Owner

@blacknight2018
I think specifying the Source IP of the outgoing packet isn't enough on Linux. Infact the older version of gdp didn't BindToDevice at all. However this doesn't guarantee that the same interface will be used whose IP address is specified as the source IP.

Linux uses the weak system model.
Check this: https://unix.stackexchange.com/questions/418765/why-does-linux-network-traffic-only-go-through-eth0

Policy based routing or Binding to the interface is the workaround. GDP does the second.

@SirSAC
Copy link

SirSAC commented Nov 11, 2021

Hello, BindToDevice work too for android but the source of an a site needs to be an IP address instead of link address, anyway my phone is not working and not existing anymore by battery issues because made in china and act like a mini bomb in the pocket.

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

3 participants