|
@ -2,7 +2,9 @@ package main |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"XProxy/cmd/asset" |
|
|
"XProxy/cmd/asset" |
|
|
|
|
|
"XProxy/cmd/common" |
|
|
"XProxy/cmd/config" |
|
|
"XProxy/cmd/config" |
|
|
|
|
|
"XProxy/cmd/dhcp" |
|
|
"XProxy/cmd/network" |
|
|
"XProxy/cmd/network" |
|
|
"XProxy/cmd/process" |
|
|
"XProxy/cmd/process" |
|
|
"XProxy/cmd/proxy" |
|
|
"XProxy/cmd/proxy" |
|
@ -13,6 +15,7 @@ import ( |
|
|
"path" |
|
|
"path" |
|
|
"strconv" |
|
|
"strconv" |
|
|
"syscall" |
|
|
"syscall" |
|
|
|
|
|
"time" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func runProcess(env []string, command ...string) { |
|
|
func runProcess(env []string, command ...string) { |
|
@ -36,6 +39,14 @@ func loadRadvd(settings *config.Config) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func loadDhcp(settings *config.Config) { |
|
|
|
|
|
common.CreateFolder(dhcp.WorkDir) |
|
|
|
|
|
if settings.DHCP.IPv4.Enable || settings.DHCP.IPv6.Enable { |
|
|
|
|
|
common.CreateFolder(path.Join(exposeDir, "dhcp")) |
|
|
|
|
|
dhcp.Load(&settings.DHCP) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func loadAsset(settings *config.Config) { |
|
|
func loadAsset(settings *config.Config) { |
|
|
if settings.Asset.Disable { |
|
|
if settings.Asset.Disable { |
|
|
log.Infof("Skip loading asset") |
|
|
log.Infof("Skip loading asset") |
|
@ -84,3 +95,25 @@ func runRadvd(settings *config.Config) { |
|
|
log.Infof("Skip running radvd") |
|
|
log.Infof("Skip running radvd") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func runDhcp(settings *config.Config) { |
|
|
|
|
|
leaseDir := path.Join(exposeDir, "dhcp") |
|
|
|
|
|
if settings.DHCP.IPv4.Enable { |
|
|
|
|
|
v4Leases := path.Join(leaseDir, "dhcp4.leases") |
|
|
|
|
|
v4Config := path.Join(dhcp.WorkDir, "dhcp4.conf") |
|
|
|
|
|
if !common.IsFileExist(v4Leases) { |
|
|
|
|
|
common.WriteFile(v4Leases, "", true) |
|
|
|
|
|
} |
|
|
|
|
|
runProcess(nil, "dhcpd", "-4", "-f", "-cf", v4Config, "-lf", v4Leases) |
|
|
|
|
|
time.Sleep(time.Second) // wait 1s for avoid cluttered output
|
|
|
|
|
|
} |
|
|
|
|
|
if settings.DHCP.IPv6.Enable { |
|
|
|
|
|
v6Leases := path.Join(leaseDir, "dhcp6.leases") |
|
|
|
|
|
v6Config := path.Join(dhcp.WorkDir, "dhcp6.conf") |
|
|
|
|
|
if !common.IsFileExist(v6Leases) { |
|
|
|
|
|
common.WriteFile(v6Leases, "", true) |
|
|
|
|
|
} |
|
|
|
|
|
runProcess(nil, "dhcpd", "-6", "-f", "-cf", v6Config, "-lf", v6Leases) |
|
|
|
|
|
time.Sleep(time.Second) // wait 1s for avoid cluttered output
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|