Skip to content

Commit 23e404b

Browse files
authored
Merge pull request #36 from fosrl/dev
0.9.0
2 parents 1cf95b6 + 6578b63 commit 23e404b

6 files changed

Lines changed: 113 additions & 8 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @oschwartz10612 @miloschwartz

config/config.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const (
2222
DefaultPrimaryDNS = "1.1.1.1"
2323
DefaultDNSOverride = true
2424
DefaultDNSTunnel = false
25+
DefaultMTU = 1280
2526
)
2627

2728
// Config represents the per-user application configuration stored under
@@ -31,6 +32,7 @@ type Config struct {
3132
DNSTunnel *bool `json:"dnsTunnel,omitempty"`
3233
PrimaryDNS *string `json:"primaryDNS,omitempty"`
3334
SecondaryDNS *string `json:"secondaryDNS,omitempty"`
35+
MTU *int `json:"mtu,omitempty"`
3436
DefaultServerURL *string `json:"defaultServerURL,omitempty"`
3537
UserSettingsDisabled *bool `json:"userSettingsDisabled,omitempty"`
3638
AuthPath *string `json:"authPath,omitempty"`
@@ -198,6 +200,17 @@ func (cm *ConfigManager) GetSecondaryDNS() string {
198200
return ""
199201
}
200202

203+
// GetMTU returns the MTU from config or default if not set
204+
func (cm *ConfigManager) GetMTU() int {
205+
cm.mu.RLock()
206+
defer cm.mu.RUnlock()
207+
208+
if cm.config != nil && cm.config.MTU != nil && *cm.config.MTU > 0 {
209+
return *cm.config.MTU
210+
}
211+
return DefaultMTU
212+
}
213+
201214
// GetDefaultServerURL returns the default server URL from config or empty string if not set
202215
func (cm *ConfigManager) GetDefaultServerURL() string {
203216
cm.mu.RLock()
@@ -332,6 +345,17 @@ func (cm *ConfigManager) SetSecondaryDNS(value string) bool {
332345
return cm.save(cfg)
333346
}
334347

348+
// SetMTU sets the MTU and saves to config
349+
func (cm *ConfigManager) SetMTU(value int) bool {
350+
cm.mu.Lock()
351+
defer cm.mu.Unlock()
352+
353+
// Get current config and copy it to preserve all fields
354+
cfg := cm.getConfigCopy()
355+
cfg.MTU = &value
356+
return cm.save(cfg)
357+
}
358+
335359
func LoadSystemConfig() *SystemConfig {
336360
configPath := filepath.Join(GetProgramDataDir(), ConfigFileName)
337361

@@ -418,6 +442,10 @@ func mergeConfig(base, override *Config) *Config {
418442
v := *override.SecondaryDNS
419443
merged.SecondaryDNS = &v
420444
}
445+
if override.MTU != nil {
446+
v := *override.MTU
447+
merged.MTU = &v
448+
}
421449
if override.DefaultServerURL != nil {
422450
v := *override.DefaultServerURL
423451
merged.DefaultServerURL = &v
@@ -461,6 +489,10 @@ func copyConfig(src *Config) *Config {
461489
secondaryDNS := *src.SecondaryDNS
462490
cfg.SecondaryDNS = &secondaryDNS
463491
}
492+
if src.MTU != nil {
493+
mtu := *src.MTU
494+
cfg.MTU = &mtu
495+
}
464496
if src.DefaultServerURL != nil {
465497
defaultServerURL := *src.DefaultServerURL
466498
cfg.DefaultServerURL = &defaultServerURL

pangolin.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
33
<Package Name="Pangolin"
44
Language="1033"
5-
Version="0.8.1"
5+
Version="0.9.0"
66
Manufacturer="Fossorial"
77
UpgradeCode="165F13D3-9A2F-4AF7-9C68-474A8256B274"
88
Compressed="yes">

tunnel/manager.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (tm *Manager) buildConfig() (Config, error) {
184184
ID: olmId,
185185
Secret: olmSecret,
186186
UserToken: userToken,
187-
MTU: 1280,
187+
MTU: tm.configManager.GetMTU(),
188188
Holepunch: true,
189189
PingIntervalSeconds: 5,
190190
PingTimeoutSeconds: 5,
@@ -374,11 +374,11 @@ type OLMStatusError struct {
374374
// sessionExpiredErrorCodes are OLM/connection error codes that mean session expired or unauthorized.
375375
// When the connection reports one of these before fully established, we set session-expired state.
376376
var sessionExpiredErrorCodes = map[string]struct{}{
377-
"UNAUTHORIZED": {},
378-
"SESSION_EXPIRED": {},
379-
"ORG_ACCESS_POLICY_SESSION_EXPIRED": {},
380-
"INVALID_USER_SESSION": {},
381-
"USER_ID_NOT_FOUND": {},
377+
"UNAUTHORIZED": {},
378+
"SESSION_EXPIRED": {},
379+
"ORG_ACCESS_POLICY_SESSION_EXPIRED": {},
380+
"INVALID_USER_SESSION": {},
381+
"USER_ID_NOT_FOUND": {},
382382
}
383383

384384
// OLMStatusResponse represents the status response from OLM API

ui/preferences/preferences_tab.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package preferences
44

55
import (
66
"net"
7+
"strconv"
78
"strings"
89

910
"github.com/fosrl/newt/logger"
@@ -21,11 +22,17 @@ type PreferencesTab struct {
2122
dnsTunnelCheckBox *walk.CheckBox
2223
primaryDNSEdit *walk.LineEdit
2324
secondaryDNSEdit *walk.LineEdit
25+
mtuEdit *walk.LineEdit
2426
saveButton *walk.PushButton
2527
configManager *config.ConfigManager
2628
window *PreferencesWindow
2729
}
2830

31+
const (
32+
minMTU = 576
33+
maxMTU = 9000
34+
)
35+
2936
// NewPreferencesTab creates a new preferences tab
3037
func NewPreferencesTab(cm *config.ConfigManager) *PreferencesTab {
3138
return &PreferencesTab{
@@ -220,6 +227,49 @@ func (pt *PreferencesTab) Create(parent *walk.TabWidget) (*walk.TabPage, error)
220227
// Spacer
221228
walk.NewHSpacer(secondaryDNSContainer)
222229

230+
// Advanced section title
231+
advancedSectionTitle, err := walk.NewLabel(pt.contentContainer)
232+
if err != nil {
233+
return nil, err
234+
}
235+
advancedSectionTitle.SetText("Advanced")
236+
if font != nil {
237+
advancedSectionTitle.SetFont(font)
238+
}
239+
240+
// MTU section
241+
mtuContainer, err := walk.NewComposite(pt.contentContainer)
242+
if err != nil {
243+
return nil, err
244+
}
245+
mtuLayout := walk.NewHBoxLayout()
246+
mtuLayout.SetMargins(walk.Margins{})
247+
mtuLayout.SetSpacing(12)
248+
mtuContainer.SetLayout(mtuLayout)
249+
250+
mtuLabel, err := walk.NewLabel(mtuContainer)
251+
if err != nil {
252+
return nil, err
253+
}
254+
mtuLabel.SetText("MTU")
255+
mtuLabel.SetMinMaxSize(walk.Size{Width: 200, Height: 0}, walk.Size{Width: 200, Height: 0})
256+
257+
if pt.mtuEdit, err = walk.NewLineEdit(mtuContainer); err != nil {
258+
return nil, err
259+
}
260+
pt.mtuEdit.SetText(strconv.Itoa(pt.configManager.GetMTU()))
261+
262+
// Spacer
263+
walk.NewHSpacer(mtuContainer)
264+
265+
mtuDescLabel, err := walk.NewLabel(pt.contentContainer)
266+
if err != nil {
267+
return nil, err
268+
}
269+
mtuDescLabel.SetText("Your sites must be configured to use the same MTU value.")
270+
mtuDescLabel.SetTextColor(walk.RGB(100, 100, 100))
271+
mtuDescLabel.SetMinMaxSize(walk.Size{}, walk.Size{Width: 400, Height: 0})
272+
223273
// Add spacer to fill remaining space
224274
walk.NewVSpacer(pt.contentContainer)
225275

@@ -282,6 +332,26 @@ func (pt *PreferencesTab) onSave() {
282332
dnsTunnel := pt.dnsTunnelCheckBox.Checked()
283333
primaryDNS := strings.TrimSpace(pt.primaryDNSEdit.Text())
284334
secondaryDNS := strings.TrimSpace(pt.secondaryDNSEdit.Text())
335+
mtuText := strings.TrimSpace(pt.mtuEdit.Text())
336+
mtu, err := strconv.Atoi(mtuText)
337+
if mtuText == "" || err != nil || mtu < minMTU || mtu > maxMTU {
338+
// Restore to current config value
339+
currentValue := strconv.Itoa(pt.configManager.GetMTU())
340+
pt.mtuEdit.SetText(currentValue)
341+
var owner walk.Form
342+
if pt.window != nil {
343+
owner = pt.window
344+
}
345+
td := walk.NewTaskDialog()
346+
_, _ = td.Show(walk.TaskDialogOpts{
347+
Owner: owner,
348+
Title: "Invalid Input",
349+
Content: "MTU must be a whole number between 576 and 9000.",
350+
IconSystem: walk.TaskDialogSystemIconWarning,
351+
CommonButtons: win.TDCBF_OK_BUTTON,
352+
})
353+
return
354+
}
285355

286356
// Validate primary DNS (required)
287357
if primaryDNS == "" {
@@ -356,9 +426,11 @@ func (pt *PreferencesTab) onSave() {
356426
dnsOverrideVal := dnsOverride
357427
dnsTunnelVal := dnsTunnel
358428
primaryDNSVal := primaryDNS
429+
mtuVal := mtu
359430
cfg.DNSOverride = &dnsOverrideVal
360431
cfg.DNSTunnel = &dnsTunnelVal
361432
cfg.PrimaryDNS = &primaryDNSVal
433+
cfg.MTU = &mtuVal
362434
if secondaryDNS != "" {
363435
cfg.SecondaryDNS = &secondaryDNS
364436
} else {

version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
package version
44

55
const (
6-
Number = "0.8.1"
6+
Number = "0.9.0"
77
)

0 commit comments

Comments
 (0)