Skip to content

Commit 45f409c

Browse files
committed
config: update defaults
- update rus-2 bootstrap peer IP - change subnet from 10.66.0.1/24 to 10.66.0.1/16 - enable HttpListenOnAdminHost by default only for awl-tray. For Android it always fails, and for server version `awl` it's just useless
1 parent dbe03e9 commit 45f409c

17 files changed

Lines changed: 64 additions & 54 deletions

application.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ func (a *Application) Init(ctx context.Context, tunDevice tun.Device) error {
201201
return nil
202202
}
203203

204-
func (a *Application) SetupLoggerAndConfig() *log.ZapEventLogger {
204+
func (a *Application) SetupLoggerAndConfig(appType config.AppType) *log.ZapEventLogger {
205205
a.Eventbus = eventbus.NewBus()
206206
// Config
207-
conf, loadConfigErr := config.LoadConfig(a.Eventbus)
207+
conf, loadConfigErr := config.LoadConfig(appType, a.Eventbus)
208208
if loadConfigErr != nil {
209-
conf = config.NewConfig(a.Eventbus)
209+
conf = config.NewConfig(appType, a.Eventbus)
210210
}
211211

212212
// Logger

application_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ func TestUpdatePeerSettingsIPAddr(t *testing.T) {
568568
{"different network", "192.168.1.1"},
569569
{"next network up", "10.67.0.5"},
570570
{"next network down", "10.65.255.255"},
571-
{"same class B different C", "10.66.1.1"},
571+
{"same class B different C", "10.67.1.1"},
572572
}
573573

574574
for _, tc := range testCases {
@@ -581,7 +581,7 @@ func TestUpdatePeerSettingsIPAddr(t *testing.T) {
581581
AllowUsingAsExitNode: peer2Config.WeAllowUsingAsExitNode,
582582
})
583583
ts.Error(err)
584-
ts.ErrorContains(err, "IP "+tc.ip+" does not belong to subnet 10.66.0.0/24")
584+
ts.ErrorContains(err, "IP "+tc.ip+" does not belong to subnet 10.66.0.0/16")
585585
})
586586
}
587587
})

cli/cli.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ var defaultApiAddr = "127.0.0.1:" + strconv.Itoa(config.DefaultHTTPPort)
3232
var binaryName = path.Base(os.Args[0])
3333

3434
type Application struct {
35-
logger *log.ZapEventLogger
36-
api *apiclient.Client
37-
cliapp *cli.App
38-
updateType update.ApplicationType
35+
logger *log.ZapEventLogger
36+
api *apiclient.Client
37+
cliapp *cli.App
38+
appType config.AppType
3939
}
4040

41-
func New(updateType update.ApplicationType) *Application {
41+
func New(appType config.AppType) *Application {
4242
app := new(Application)
4343
app.logger = log.Logger("awl/cli")
44-
app.updateType = updateType
44+
app.appType = appType
4545
app.init()
4646

4747
return app
@@ -518,12 +518,12 @@ func (a *Application) init() {
518518
Action: func(c *cli.Context) error {
519519
_, _ = fmt.Fprintf(a.cliapp.Writer, "current version: %s\n", config.Version)
520520

521-
conf, err := config.LoadConfig(eventbus.NewBus())
521+
conf, err := config.LoadConfig(a.appType, eventbus.NewBus())
522522
if err != nil {
523523
return fmt.Errorf("update: read config: %v", err)
524524
}
525525

526-
updService, err := update.NewUpdateService(conf, a.logger, a.updateType)
526+
updService, err := update.NewUpdateService(conf, a.logger, a.appType)
527527
if err != nil {
528528
return fmt.Errorf("update: create update service: %v", err)
529529
}
@@ -570,7 +570,7 @@ func (a *Application) initApiConnection(c *cli.Context) error {
570570
return a.initApiFromAddr(apiAddr, username, password)
571571
}
572572

573-
conf, errConfig := config.LoadConfig(eventbus.NewBus())
573+
conf, errConfig := config.LoadConfig(a.appType, eventbus.NewBus())
574574
if errConfig == nil {
575575
if username == "" && password == "" {
576576
username = conf.HttpBasicAuth.Username

cli_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"github.com/stretchr/testify/require"
1212

1313
"github.com/anywherelan/awl/cli"
14+
"github.com/anywherelan/awl/config"
1415
"github.com/anywherelan/awl/entity"
15-
"github.com/anywherelan/awl/update"
1616
)
1717

1818
// runCLIAddr runs a CLI command against the given API address and returns stdout output.
1919
func runCLIAddr(addr string, args ...string) (string, error) {
20-
app := cli.New(update.AppTypeAwl)
20+
app := cli.New(config.AppTypeAwl)
2121
var buf bytes.Buffer
2222
fullArgs := append([]string{"cli", "--api_addr", addr}, args...)
2323
err := app.RunWithWriter(fullArgs, &buf)

cmd/awl-tray/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ import (
2323
"github.com/anywherelan/awl/cli"
2424
"github.com/anywherelan/awl/config"
2525
"github.com/anywherelan/awl/embeds"
26-
"github.com/anywherelan/awl/update"
2726
)
2827

28+
const appType = config.AppTypeAwlTray
29+
2930
var (
3031
app *awl.Application
3132
logger *log.ZapEventLogger
@@ -35,11 +36,11 @@ func getConfig() (*config.Config, error) {
3536
if app != nil {
3637
return app.Conf, nil
3738
}
38-
return config.LoadConfig(eventbus.NewBus())
39+
return config.LoadConfig(appType, eventbus.NewBus())
3940
}
4041

4142
func main() {
42-
cli.New(update.AppTypeAwlTray).Run()
43+
cli.New(appType).Run()
4344

4445
initOSSpecificHacks()
4546

@@ -105,7 +106,7 @@ func InitServer() (err error) {
105106
app = awl.New()
106107
// TODO: setup logger in main(), before systray and others
107108
// now we can have panics because of this
108-
logger = app.SetupLoggerAndConfig()
109+
logger = app.SetupLoggerAndConfig(appType)
109110

110111
err = app.Init(context.Background(), nil)
111112
if err != nil {

cmd/awl-tray/tray.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func onClickUpdateMenu() error {
402402
if err != nil {
403403
return fmt.Errorf("update: read config: %v", err)
404404
}
405-
updService, err := update.NewUpdateService(conf, logger, update.AppTypeAwlTray)
405+
updService, err := update.NewUpdateService(conf, logger, appType)
406406
if err != nil {
407407
return fmt.Errorf("update: create update service: %v", err)
408408
}
@@ -438,7 +438,7 @@ func checkForUpdatesWithDesktopNotification() {
438438
logger.Errorf("update auto check: load config: %v", err)
439439
return
440440
}
441-
updService, err := update.NewUpdateService(conf, logger, update.AppTypeAwlTray)
441+
updService, err := update.NewUpdateService(conf, logger, appType)
442442
if err != nil {
443443
logger.Errorf("update auto check: creating update service: %v", err)
444444
return

cmd/awl/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import (
99
"syscall"
1010
"time"
1111

12+
"github.com/ipfs/go-log/v2"
13+
1214
"github.com/anywherelan/awl"
1315
"github.com/anywherelan/awl/cli"
1416
"github.com/anywherelan/awl/config"
1517
"github.com/anywherelan/awl/update"
16-
"github.com/ipfs/go-log/v2"
1718
)
1819

20+
const appType = config.AppTypeAwl
21+
1922
func main() {
20-
cli.New(update.AppTypeAwl).Run()
23+
cli.New(appType).Run()
2124

2225
uid := os.Geteuid()
2326
if uid == 0 {
@@ -30,7 +33,7 @@ func main() {
3033
}
3134

3235
app := awl.New()
33-
logger := app.SetupLoggerAndConfig()
36+
logger := app.SetupLoggerAndConfig(appType)
3437
ctx, ctxCancel := context.WithCancel(context.Background())
3538

3639
err := app.Init(ctx, nil)
@@ -82,7 +85,7 @@ func main() {
8285
}
8386

8487
func checkForUpdates(conf *config.Config, logger *log.ZapEventLogger) {
85-
updService, err := update.NewUpdateService(conf, logger, update.AppTypeAwl)
88+
updService, err := update.NewUpdateService(conf, logger, appType)
8689
if err != nil {
8790
logger.Errorf("update auto check: creating update service: %v", err)
8891
return

cmd/gomobile-lib/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"github.com/anywherelan/awl/vpn/sockmark"
1717
)
1818

19+
const appType = config.AppTypeAwlAndroid
20+
1921
var (
2022
globalApp *awl.Application
2123
globalDataDir string
@@ -37,9 +39,9 @@ func GetConfig() string {
3739
panic("call to GetConfig before Setup")
3840
}
3941

40-
conf, loadConfigErr := config.LoadConfig(eventbus.NewBus())
42+
conf, loadConfigErr := config.LoadConfig(appType, eventbus.NewBus())
4143
if loadConfigErr != nil {
42-
conf = config.NewConfig(eventbus.NewBus())
44+
conf = config.NewConfig(appType, eventbus.NewBus())
4345
}
4446

4547
data := conf.Export()
@@ -77,7 +79,7 @@ func StartServer(tunFD int32, protector SocketProtector) (err error) {
7779
}()
7880

7981
globalApp = awl.New()
80-
globalApp.SetupLoggerAndConfig()
82+
globalApp.SetupLoggerAndConfig(appType)
8183
globalApp.SockMarker = sockmark.NewAndroid(protectorToFunc(protector))
8284

8385
// A tunFD of 0 means the host did not establish a VPN interface (VPN

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type (
4343
sync.RWMutex `swaggerignore:"true"`
4444
dataDir string
4545
emitter awlevent.Emitter
46+
appType AppType
4647

4748
Version string `json:"version"`
4849
LoggerLevel string `json:"loggerLevel"`

config/network_addr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
const (
1111
DefaultVPNInterfaceName = "awl0"
1212
// TODO: generate subnets if this has already taken
13-
DefaultVPNNetworkSubnet = "10.66.0.1/24"
13+
DefaultVPNNetworkSubnet = "10.66.0.1/16"
1414
)
1515

1616
func (c *Config) VPNLocalIPMask() (net.IP, net.IPMask) {

0 commit comments

Comments
 (0)