mirror of https://github.com/dnomd343/XProxy.git
dnomd343
2 years ago
5 changed files with 78 additions and 83 deletions
@ -1,39 +1,48 @@ |
|||||
package main |
package main |
||||
|
|
||||
import ( |
import ( |
||||
|
"XProxy/cmd/config" |
||||
"XProxy/cmd/network" |
"XProxy/cmd/network" |
||||
"XProxy/cmd/proxy" |
|
||||
"fmt" |
"fmt" |
||||
log "github.com/sirupsen/logrus" |
log "github.com/sirupsen/logrus" |
||||
) |
) |
||||
|
|
||||
|
var exposeDir = "/xproxy" |
||||
|
|
||||
|
var v4RouteTable = 100 |
||||
|
var v6RouteTable = 106 |
||||
|
var v4TProxyPort = 7288 |
||||
|
var v6TProxyPort = 7289 |
||||
|
|
||||
|
func loadNetwork(settings *config.Config) { |
||||
|
v4Settings := network.Config{ |
||||
|
RouteTable: v4RouteTable, |
||||
|
TProxyPort: v4TProxyPort, |
||||
|
Address: settings.V4Address, |
||||
|
Gateway: settings.V4Gateway, |
||||
|
Bypass: settings.V4Bypass, |
||||
|
} |
||||
|
v6Settings := network.Config{ |
||||
|
RouteTable: v6RouteTable, |
||||
|
TProxyPort: v6TProxyPort, |
||||
|
Address: settings.V6Address, |
||||
|
Gateway: settings.V6Gateway, |
||||
|
Bypass: settings.V6Bypass, |
||||
|
} |
||||
|
network.Load(settings.DNS, v4Settings, v6Settings) |
||||
|
} |
||||
|
|
||||
func main() { |
func main() { |
||||
log.SetLevel(log.DebugLevel) |
log.SetLevel(log.DebugLevel) |
||||
|
|
||||
fmt.Println("XProxy start") |
fmt.Println("XProxy start") |
||||
|
|
||||
network.Load(nil, network.Config{ |
settings := config.Load(exposeDir + "/config.yml") |
||||
RouteTable: 100, |
fmt.Println(settings) |
||||
TProxyPort: 7288, |
|
||||
Address: "192.168.2.2", |
loadNetwork(&settings) |
||||
Gateway: "192.168.2.1", |
|
||||
Bypass: make([]string, 0), |
// TODO: load proxy
|
||||
}, network.Config{ |
// TODO: load asset
|
||||
RouteTable: 106, |
|
||||
TProxyPort: 7289, |
// TODO: start xray service
|
||||
Address: "fc00::2", |
|
||||
Gateway: "fc00::1", |
|
||||
Bypass: make([]string, 0), |
|
||||
}) |
|
||||
|
|
||||
proxy.Load("/etc/xproxy", "/xproxy", proxy.Config{ |
|
||||
Sniff: true, |
|
||||
Redirect: true, |
|
||||
V4TProxyPort: 7288, |
|
||||
V6TProxyPort: 7289, |
|
||||
LogLevel: "debug", |
|
||||
HttpInbounds: nil, |
|
||||
SocksInbounds: nil, |
|
||||
AddOnInbounds: nil, |
|
||||
}) |
|
||||
} |
} |
||||
|
@ -1,38 +0,0 @@ |
|||||
package main |
|
||||
|
|
||||
import ( |
|
||||
log "github.com/sirupsen/logrus" |
|
||||
) |
|
||||
|
|
||||
var v4Bypass []string |
|
||||
var v6Bypass []string |
|
||||
var dnsServer []string |
|
||||
|
|
||||
var v4Gateway string |
|
||||
var v4Address string |
|
||||
var v6Gateway string |
|
||||
var v6Address string |
|
||||
|
|
||||
func loadConfig(configFile string) { |
|
||||
|
|
||||
config := Config{} |
|
||||
|
|
||||
enableSniff = config.Proxy.Sniff |
|
||||
log.Infof("Connection sniff -> %v", enableSniff) |
|
||||
enableRedirect = config.Proxy.Redirect |
|
||||
log.Infof("Connection redirect -> %v", enableRedirect) |
|
||||
httpInbounds = config.Proxy.Http |
|
||||
log.Infof("Http inbounds -> %v", httpInbounds) |
|
||||
socksInbounds = config.Proxy.Socks |
|
||||
log.Infof("Socks5 inbounds -> %v", socksInbounds) |
|
||||
addOnInbounds = config.Proxy.AddOn |
|
||||
log.Infof("Add-on inbounds -> %v", addOnInbounds) |
|
||||
|
|
||||
updateCron = config.Update.Cron |
|
||||
log.Infof("Update cron -> %s", updateCron) |
|
||||
updateUrls = config.Update.Url |
|
||||
log.Infof("Update url -> %v", updateUrls) |
|
||||
|
|
||||
preScript = config.Script |
|
||||
log.Infof("Pre-script -> %v", preScript) |
|
||||
} |
|
Loading…
Reference in new issue