Skip to content

Commit 7e755db

Browse files
ddzclaude
andauthored
Resolve bare WGConfig filenames relative to parent config directory. (#204)
A WGConfig value with no path separator is now joined with the directory of the parent config file, so a wg config sitting next to the wireproxy config can be referenced by name alone. Values containing a separator (absolute or relative) keep their existing behavior. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent b200992 commit 7e755db

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

config.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"net"
88
"os"
9+
"path/filepath"
910
"strings"
1011

1112
"github.com/go-ini/ini"
@@ -540,7 +541,14 @@ func ParseConfig(path string) (*Configuration, error) {
540541
wgConf, err := root.GetKey("WGConfig")
541542
wgCfg := cfg
542543
if err == nil {
543-
wgCfg, err = ini.LoadSources(iniOpt, wgConf.String())
544+
wgPath := wgConf.String()
545+
// A bare filename (no path separators) is resolved relative to the
546+
// directory of the parent config file, so the wg config can sit
547+
// alongside the wireproxy config without needing a full path.
548+
if filepath.Base(wgPath) == wgPath {
549+
wgPath = filepath.Join(filepath.Dir(path), wgPath)
550+
}
551+
wgCfg, err = ini.LoadSources(iniOpt, wgPath)
544552
if err != nil {
545553
return nil, err
546554
}

0 commit comments

Comments
 (0)