Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

sockopts_reuseaddr.go 557B

123456789101112131415161718192021222324252627282930
  1. //go:build !windows
  2. package network
  3. import (
  4. "fmt"
  5. "syscall"
  6. "golang.org/x/sys/unix"
  7. )
  8. func setSocketReuseAddrPort(conn syscall.RawConn) error {
  9. var err error
  10. conn.Control(func(fd uintptr) { //nolint: errcheck
  11. err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1)
  12. if err != nil {
  13. err = fmt.Errorf("cannot set SO_REUSEADDR: %w", err)
  14. return
  15. }
  16. err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
  17. if err != nil {
  18. err = fmt.Errorf("cannot set SO_REUSEPORT: %w", err)
  19. }
  20. })
  21. return err
  22. }