diff --git a/lib/common/task.dart b/lib/common/task.dart index 5ae6cbf..f8edb42 100644 --- a/lib/common/task.dart +++ b/lib/common/task.dart @@ -192,7 +192,7 @@ Future> _makeRealProfileTask( rawConfig['external-controller'] = realPatchConfig.externalController.value; rawConfig['external-ui'] = ''; - rawConfig['interface-name'] = ''; + rawConfig['interface-name'] ??= ''; rawConfig['external-ui-url'] = ''; rawConfig['tcp-concurrent'] = realPatchConfig.tcpConcurrent; rawConfig['unified-delay'] = realPatchConfig.unifiedDelay; diff --git a/test/common/task_test.dart b/test/common/task_test.dart index 7c5aaec..8c96d89 100644 --- a/test/common/task_test.dart +++ b/test/common/task_test.dart @@ -261,6 +261,44 @@ void main() { } }); + test('profile output preserves an explicit interface name', () async { + final profile = await makeRealProfileTask( + const MakeRealProfileState( + profilesPath: '/tmp/flclash-interface-name-test', + profileId: 14, + rawConfig: {'interface-name': 'Campus PPPoE'}, + realPatchConfig: PatchClashConfig(), + overrideDns: false, + appendSystemDns: false, + proxyGroups: [], + rules: [], + addedRules: [], + defaultUA: 'FlClash-Test', + ), + ); + + expect(profile.a, contains('interface-name: "Campus PPPoE"')); + }); + + test('profile output keeps an unset interface name empty', () async { + final profile = await makeRealProfileTask( + const MakeRealProfileState( + profilesPath: '/tmp/flclash-interface-name-test', + profileId: 15, + rawConfig: {}, + realPatchConfig: PatchClashConfig(), + overrideDns: false, + appendSystemDns: false, + proxyGroups: [], + rules: [], + addedRules: [], + defaultUA: 'FlClash-Test', + ), + ); + + expect(profile.a, contains('interface-name: ""')); + }); + test( 'DNS overwrite does not append system DNS when the setting is disabled', () async {