Closed deputinizer closed 2 years ago
Looks like Golang is just a lot more retarded than Rust... https://github.com/golang/go/issues/39293
I can't believe they didn't add this functionality for so many years.
There should be also a field for device/interface https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/net/dial.go;l=52
LocalAddress is called that way because it expects an address, not an interface name. Golang has features that would allow working with interface names (it would just fetch interface address under the hood) but I feel like exposing address gives user more control (i.e. an interface can have multiple addresses attached, especially in case of ipv6)
Ah, wait, I see that you're using IP in repro steps, can you clarify that it's not working that way as your actual behavior showcases usage with interface name?
I feel like exposing address gives user more control (i.e. an interface can have multiple addresses attached, especially in case of ipv6)
Well, DHCP is a ducktape. Local IP changes on WiFi. Especially on public networks.
can you clarify [...]
Note: CURL does not work either [on both PI's] with local IP address. I had to specify --interface wlan0
Should work in go:
dialer := &net.Dialer{
Control: func(network, address string, conn syscall.RawConn) error {
var operr error
if err := conn.Control(func(fd uintptr) {
operr = syscall.BindToDevice(fd, "wlan1")
}); err != nil {
return err
}
return operr
},
}
Temprorary solution
while true; do sudo route del default gw 192.168.0.1 eth0; sleep 5; done
Ok, another thing. How to limit resources on raspberry pi 1B ?
-scale 1
argument seems to be the lowest already.-enable-primitive false
eats too much RAM.In stoppropaganda, i've already optimized fasthttp so it doesn't store response bytes in memory. https://github.com/deputinizer/fasthttp/commits/master https://github.com/erkexzcx/stoppropaganda/pull/103#issuecomment-1059579413
Nice. It actually works.
pi@pi2:~ $ ./db1000n -interface wlan1
...
pi@pi2:~ $ vnstat -l -i wlan1
Monitoring wlan1...
rx: 3.24 Mbit/s 296 p/s tx: 165.98 kbit/s 221 p/s
I'm a bit sad that it only works for linux as other systems don't have that particular syscall. I feel like there should be a way to hack around that by dynamically querying for the ip address of an interface in that particular function but I don't have time to check that theory yet
As for limiting the resource usage you can try using --min-interval which would introduce artificial rate limiting to the app. It's a bit hacky way but for historical reasons it works that way
Expected Behavior
I wanted to run program only on interface/device
wlan1
from Raspberry Pi 2B. HTTP Requests should be sent just like in curl:Similar problem fixed in Rust: https://github.com/hyperium/hyper/pull/2823
Actual Behavior
Running:
./db1000n -local-address wlan1
sends requests over eth0Also, choosing address given by DHCP on
wlan1
does not solve the problem. Note: On raspberry pi 1 choosing IP ofwlan1
completely disables the program [0 bit/s].Steps to Reproduce the Problem
ip a s
./db1000n -local-address 10.2.2.2
nload
orvnstat -i wlan1
Specifications