Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/mitm-socket/go/configure_tcp.go
1029 views
1
// go build !windows
2
package main
3
4
import (
5
"log"
6
"syscall"
7
)
8
9
func ConfigureSocket(ttl int, windowSize int) func(network string, addr string, c syscall.RawConn) error {
10
return func(network string, addr string, c syscall.RawConn) error {
11
if ttl == 0 && windowSize == 0 {
12
return nil
13
}
14
configErr := c.Control(func(fd uintptr) {
15
if ttl > 0 {
16
err := ConfigureTcpTtl(fd, ttl)
17
if err != nil {
18
log.Printf("Error setting IP_TTL. %#v", err)
19
}
20
}
21
if windowSize > 0 {
22
err := ConfigureTcpWindowSize(fd, windowSize)
23
if err != nil {
24
log.Printf("Error setting SO_RCVBUF. %#v", err)
25
}
26
}
27
})
28
if configErr != nil {
29
return configErr
30
}
31
return nil
32
}
33
}
34
35