mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
Add UDPProxyTunnel
This commit is contained in:
parent
d710683181
commit
8ae43d6103
2 changed files with 199 additions and 0 deletions
39
config.go
39
config.go
|
@ -33,6 +33,12 @@ type DeviceConfig struct {
|
|||
CheckAliveInterval int
|
||||
}
|
||||
|
||||
type UDPProxyTunnelConfig struct {
|
||||
BindAddress string
|
||||
Target string
|
||||
InactivityTimeout int
|
||||
}
|
||||
|
||||
type TCPClientTunnelConfig struct {
|
||||
BindAddress *net.TCPAddr
|
||||
Target string
|
||||
|
@ -434,6 +440,34 @@ func parseHTTPConfig(section *ini.Section) (RoutineSpawner, error) {
|
|||
return config, nil
|
||||
}
|
||||
|
||||
func parseUDPProxyTunnelConfig(section *ini.Section) (RoutineSpawner, error) {
|
||||
config := &UDPProxyTunnelConfig{}
|
||||
|
||||
bindAddress, err := parseString(section, "BindAddress")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.BindAddress = bindAddress
|
||||
|
||||
target, err := parseString(section, "Target")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.Target = target
|
||||
|
||||
inactivityTimeout := 0
|
||||
if sectionKey, err := section.GetKey("InactivityTimeout"); err == nil {
|
||||
timeoutVal, err := sectionKey.Int()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inactivityTimeout = timeoutVal
|
||||
}
|
||||
config.InactivityTimeout = inactivityTimeout
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// Takes a function that parses an individual section into a config, and apply it on all
|
||||
// specified sections
|
||||
func parseRoutinesConfig(routines *[]RoutineSpawner, cfg *ini.File, sectionName string, f func(*ini.Section) (RoutineSpawner, error)) error {
|
||||
|
@ -518,6 +552,11 @@ func ParseConfig(path string) (*Configuration, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
err = parseRoutinesConfig(&routinesSpawners, cfg, "UDPProxyTunnel", parseUDPProxyTunnelConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Configuration{
|
||||
Device: device,
|
||||
Routines: routinesSpawners,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue