style: rename controllers to login, cancel internal/pkg

This commit is contained in:
Mmx
2024-10-14 12:50:59 +08:00
parent e963917d87
commit 20c4d3df55
14 changed files with 31 additions and 31 deletions

View File

@@ -0,0 +1,43 @@
package http_client
import (
"crypto/tls"
"github.com/Mmx233/BitSrunLoginGo/internal/config"
"github.com/Mmx233/BitSrunLoginGo/tools"
"net"
"net/http"
"syscall"
)
func CreateClientFromEth(eth *tools.Eth) *http.Client {
dialer := net.Dialer{
Timeout: config.Timeout,
}
if eth != nil {
dialer.LocalAddr = eth.Addr
ethName := eth.Name
dialer.Control = func(network string, address string, c syscall.RawConn) error {
var opErr error
fn := func(fd uintptr) {
opErr = syscall.SetsockoptString(int(fd), syscall.SOL_SOCKET, syscall.SO_BINDTODEVICE, ethName)
}
if err := c.Control(fn); err != nil {
return err
}
if opErr != nil {
return opErr
}
return nil
}
}
return &http.Client{
Transport: &http.Transport{
DialContext: dialer.DialContext,
TLSHandshakeTimeout: config.Timeout,
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.Settings.Basic.SkipCertVerify},
Proxy: http.ProxyFromEnvironment,
},
Timeout: config.Timeout,
}
}