diff --git a/lib/core/dns_resolver.dart b/lib/core/dns_resolver.dart index 0ebbf42..1f97c7c 100644 --- a/lib/core/dns_resolver.dart +++ b/lib/core/dns_resolver.dart @@ -200,6 +200,10 @@ class DnsResolver { /// 서버들에 차례로 묻는다 (첫 서버가 답하지 않으면 다음 서버) Future<(DnsAnswer, String)> _ask(DnsConfig c, String name, int type) async { + // 이름 자체의 문제 (너무 긴 이름) 는 서버 탓이 아니다 - 묻기 전에 보고 그대로 알린다. + // 예전에는 서버마다 실패한 끝에 "DNS 서버 (…) 에 닿지 않습니다: 주소 이름이 너무 깁니다: <이름>" (닿지 않음) 으로 바뀌어 + // DNS 안내가 뜨고 작업 기록에 연 사이트 이름이 남았다 (15 지적 · 관리자 10/17) + buildDnsQuery(name, type); if (c.mode == 'doh') return (await _doh(c, name, type), c.label); final servers = c.servers; if (servers.isEmpty) { diff --git a/test/dns_proxy_test.dart b/test/dns_proxy_test.dart index 008d432..6fc1238 100644 --- a/test/dns_proxy_test.dart +++ b/test/dns_proxy_test.dart @@ -477,6 +477,31 @@ void main() { expect((s.torKeepData, s.torHomeUrl, s.torJavaScript, s.torNoticeSeen), (false, 'https://check.torproject.org/', true, false)); }); + test('너무 긴 이름은 이름 탓 (닿지 않음 아님) - DNS 안내 · 작업 기록에 사이트 이름이 남지 않는다 (15 지적)', () async { + final long = '${'a' * 70}.example.com'; + for (final c in [custom('192.0.2.1'), const DnsConfig(mode: 'doh', dohUrl: 'https://192.0.2.1/dns-query', primary: '192.0.2.1')]) { + final r = DnsResolver(config: () => c, timeout: const Duration(milliseconds: 300)); + Object? err; + try { + await r.lookup(long); + } catch (e) { + err = e; + } + expect(err, isA(), reason: c.mode); + expect((err! as DnsException).unreachable, isFalse, reason: '${c.mode}: 서버에 닿지 않음으로 보지 않는다'); + expect('$err', contains('주소 이름이 너무 깁니다')); + // 작업 기록: 닿지 않음만 남기므로 이 실패는 기록하지 않는다 (사이트 이름이 남지 않음) + final g = NetGuard.instance; + final logged = []; + final oldLog = g.log; + g.log = logged.add; + addTearDown(() => g.log = oldLog); + g.reportError(long, err); + expect(logged.where((l) => l.contains('aaaa')), isEmpty); + expect(g.failure.value, isNull, reason: 'DNS 안내 (닿지 않음) 를 띄우지 않는다'); + } + }); + test('247 · 249: 닿지 않는 DNS - 앱의 HTTP 오류를 사용자 글로 · 상태는 다시 답하거나 설정을 바꿀 때까지 남음', () async { final g = NetGuard.instance; final old = HttpOverrides.current;