mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
Support for MTU parameter #12
This commit is contained in:
parent
623c172931
commit
1532ed59f1
2 changed files with 17 additions and 2 deletions
|
@ -50,6 +50,9 @@ DNS = 1.1.1.1
|
|||
# If you don't know what this is, then you probably don't need it.
|
||||
#PreSharedKey = UItQuvLsyh50ucXHfjF0bbR4IIpVBd74lwKc8uIPXXs=
|
||||
|
||||
# MTU is the maximum transmission unit size, By default this is set to 1420.
|
||||
# MTU = 1234
|
||||
|
||||
# TCPClientTunnel is a tunnel listening on your machine,
|
||||
# and it forwards any TCP traffic received to the specified target via wireguard.
|
||||
# Flow:
|
||||
|
|
16
main.go
16
main.go
|
@ -32,6 +32,7 @@ type DeviceSetting struct {
|
|||
ipcRequest string
|
||||
dns []netip.Addr
|
||||
deviceAddr *netip.Addr
|
||||
mtu int
|
||||
}
|
||||
|
||||
type NetstackDNSResolver struct {
|
||||
|
@ -220,6 +221,17 @@ func createIPCRequest(conf Configuration) (*DeviceSetting, error) {
|
|||
}
|
||||
}
|
||||
|
||||
mtu := int64(1420)
|
||||
if mtuOpt, ok := root["mtu"]; ok {
|
||||
mtu, err = strconv.ParseInt(mtuOpt, 10, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if mtu < 0 {
|
||||
mtu = 0
|
||||
}
|
||||
}
|
||||
|
||||
request := fmt.Sprintf(`private_key=%s
|
||||
public_key=%s
|
||||
endpoint=%s
|
||||
|
@ -227,7 +239,7 @@ persistent_keepalive_interval=%d
|
|||
preshared_key=%s
|
||||
allowed_ip=0.0.0.0/0`, selfSK, peerPK, peerEndpoint, keepAlive, preSharedKey)
|
||||
|
||||
setting := &DeviceSetting{ipcRequest: request, dns: dns, deviceAddr: &selfEndpoint}
|
||||
setting := &DeviceSetting{ipcRequest: request, dns: dns, deviceAddr: &selfEndpoint, mtu: int(mtu)}
|
||||
return setting, nil
|
||||
}
|
||||
|
||||
|
@ -366,7 +378,7 @@ func tcpServerRoutine(config map[string]string) (func(*netstack.Net), error) {
|
|||
}
|
||||
|
||||
func startWireguard(setting *DeviceSetting) (*netstack.Net, error) {
|
||||
tun, tnet, err := netstack.CreateNetTUN([]netip.Addr{*(setting.deviceAddr)}, setting.dns, 1420)
|
||||
tun, tnet, err := netstack.CreateNetTUN([]netip.Addr{*(setting.deviceAddr)}, setting.dns, setting.mtu)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue