mirror of https://github.com/dnomd343/XProxy.git
dnomd343
2 years ago
7 changed files with 90 additions and 83 deletions
@ -0,0 +1,45 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"XProxy/cmd/asset" |
|||
"XProxy/cmd/config" |
|||
"XProxy/cmd/network" |
|||
"XProxy/cmd/proxy" |
|||
) |
|||
|
|||
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 loadProxy(settings *config.Config) { |
|||
proxy.Load(configDir, exposeDir, proxy.Config{ |
|||
Sniff: settings.EnableSniff, |
|||
Redirect: settings.EnableRedirect, |
|||
V4TProxyPort: v4TProxyPort, |
|||
V6TProxyPort: v6TProxyPort, |
|||
LogLevel: "warning", |
|||
HttpInbounds: settings.HttpInbounds, |
|||
SocksInbounds: settings.SocksInbounds, |
|||
AddOnInbounds: settings.AddOnInbounds, |
|||
}) |
|||
} |
|||
|
|||
func loadAsset(settings *config.Config) { |
|||
asset.LoadGeoSite(assetFile, assetDir) |
|||
asset.LoadGeoIp(assetFile, assetDir) |
|||
asset.AutoUpdate(settings.UpdateCron, settings.UpdateUrls, assetDir) |
|||
} |
@ -0,0 +1,32 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"XProxy/cmd/config" |
|||
"fmt" |
|||
log "github.com/sirupsen/logrus" |
|||
) |
|||
|
|||
var version = "dev" |
|||
|
|||
var v4RouteTable = 100 |
|||
var v6RouteTable = 106 |
|||
var v4TProxyPort = 7288 |
|||
var v6TProxyPort = 7289 |
|||
|
|||
var exposeDir = "/xproxy" |
|||
var configDir = "/etc/xproxy" |
|||
var assetFile = "/assets.tar.xz" |
|||
var assetDir = exposeDir + "/assets" |
|||
var configFile = exposeDir + "/config.yml" |
|||
|
|||
func main() { |
|||
log.SetLevel(log.DebugLevel) |
|||
fmt.Println("XProxy start -> version =", version) |
|||
|
|||
settings := config.Load(configFile) |
|||
loadNetwork(&settings) |
|||
loadProxy(&settings) |
|||
loadAsset(&settings) |
|||
|
|||
// TODO: start xray service
|
|||
} |
@ -1,48 +0,0 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"XProxy/cmd/config" |
|||
"XProxy/cmd/network" |
|||
"fmt" |
|||
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() { |
|||
log.SetLevel(log.DebugLevel) |
|||
fmt.Println("XProxy start") |
|||
|
|||
settings := config.Load(exposeDir + "/config.yml") |
|||
fmt.Println(settings) |
|||
|
|||
loadNetwork(&settings) |
|||
|
|||
// TODO: load proxy
|
|||
// TODO: load asset
|
|||
|
|||
// TODO: start xray service
|
|||
} |
Loading…
Reference in new issue