Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ type RawTun struct {
Stack C.TUNStack `yaml:"stack" json:"stack"`
DNSHijack []string `yaml:"dns-hijack" json:"dns-hijack"`
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
AutoDetectInterface bool `yaml:"auto-detect-interface"`
AutoDetectInterface bool `yaml:"auto-detect-interface" json:"auto-detect-interface"`

MTU uint32 `yaml:"mtu" json:"mtu,omitempty"`
GSO bool `yaml:"gso" json:"gso,omitempty"`
Expand Down
25 changes: 25 additions & 0 deletions config/raw_tun_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package config

import (
"encoding/json"
"testing"
)

func TestRawTunJSONUsesMihomoAutoDetectInterfaceKey(t *testing.T) {
data, err := json.Marshal(RawTun{AutoDetectInterface: true})
if err != nil {
t.Fatalf("marshal RawTun: %v", err)
}

var fields map[string]any
if err := json.Unmarshal(data, &fields); err != nil {
t.Fatalf("unmarshal RawTun JSON: %v", err)
}

if got := fields["auto-detect-interface"]; got != true {
t.Fatalf("auto-detect-interface = %v, want true", got)
}
if _, found := fields["AutoDetectInterface"]; found {
t.Fatal("unexpected Go field name in RawTun JSON")
}
}