mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
allow importing a wireguard config #27
This commit is contained in:
parent
ec8a7f9a2a
commit
6b05fcc6ca
2 changed files with 33 additions and 5 deletions
18
README.md
18
README.md
|
@ -49,7 +49,7 @@ go build ./cmd/wireproxy
|
||||||
|
|
||||||
# Sample config file
|
# Sample config file
|
||||||
```
|
```
|
||||||
# The [Interface] and [Peer] configurations follow the same sematics and meaning
|
# The [Interface] and [Peer] configurations follow the same semantics and meaning
|
||||||
# of a wg-quick configuration. To understand what these fields mean, please refer to:
|
# of a wg-quick configuration. To understand what these fields mean, please refer to:
|
||||||
# https://wiki.archlinux.org/title/WireGuard#Persistent_configuration
|
# https://wiki.archlinux.org/title/WireGuard#Persistent_configuration
|
||||||
# https://www.wireguard.com/#simple-network-interface
|
# https://www.wireguard.com/#simple-network-interface
|
||||||
|
@ -92,6 +92,22 @@ BindAddress = 127.0.0.1:25344
|
||||||
#Password = ...
|
#Password = ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively, if you already have a wireguard config, you can import it in the
|
||||||
|
wireproxy config file like this:
|
||||||
|
```
|
||||||
|
WGConfig = <path to the wireguard config>
|
||||||
|
|
||||||
|
# Same semantics as above
|
||||||
|
[TCPClientTunnel]
|
||||||
|
...
|
||||||
|
|
||||||
|
[TCPServerTunnel]
|
||||||
|
...
|
||||||
|
|
||||||
|
[Socks5]
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Stargazers over time
|
## Stargazers over time
|
||||||
|
|
||||||
|
|
20
config.go
20
config.go
|
@ -311,10 +311,12 @@ func parseRoutinesConfig(routines *[]RoutineSpawner, cfg *ini.File, sectionName
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseConfig(path string) (*Configuration, error) {
|
func ParseConfig(path string) (*Configuration, error) {
|
||||||
cfg, err := ini.LoadSources(ini.LoadOptions{
|
iniOpt := ini.LoadOptions{
|
||||||
Insensitive: true,
|
Insensitive: true,
|
||||||
AllowShadows: true,
|
AllowShadows: true,
|
||||||
}, path)
|
}
|
||||||
|
|
||||||
|
cfg, err := ini.LoadSources(iniOpt, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -325,12 +327,22 @@ func ParseConfig(path string) (*Configuration, error) {
|
||||||
MTU: 1420,
|
MTU: 1420,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ParseInterface(cfg, device)
|
root := cfg.Section("")
|
||||||
|
wgConf, err := root.GetKey("WGConfig")
|
||||||
|
wgCfg := cfg
|
||||||
|
if err == nil {
|
||||||
|
wgCfg, err = ini.LoadSources(iniOpt, wgConf.String())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = ParseInterface(wgCfg, device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ParsePeer(cfg, device)
|
err = ParsePeer(wgCfg, device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue