Skip to content

refactor: change fetchIP to return IP list with interface types#22

Merged
minjae999 merged 1 commit intomainfrom
feature/fetch_ip_list
Feb 11, 2026
Merged

refactor: change fetchIP to return IP list with interface types#22
minjae999 merged 1 commit intomainfrom
feature/fetch_ip_list

Conversation

@minjae999
Copy link
Contributor

No description provided.

@minjae999 minjae999 requested a review from pokeum February 11, 2026 05:02
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Walkthrough

NetworkFetcher의 IP 주소 검색 로직을 단일 문자열에서 배열 기반 접근 방식으로 변경했습니다. 새로운 공개 IPInterfaceType 구조체를 도입하고, Network.ip 속성 타입을 String?에서 [IP]로 변경하며, 오류 처리를 nil 반환에서 빈 배열 반환으로 업데이트했습니다.

Changes

Cohort / File(s) Summary
IP 주소 데이터 구조 및 API 변경
Source/AppleFetcher/Implement/NetworkFetcher.swift
공개 구조체 IP(ip: String, interfaceType: InterfaceType)와 InterfaceType(name: String, family: sa_family_t) 추가. Network.ip 타입을 String?에서 [IP]로 변경. fetchIP() 함수를 fetchIPList() -> [IP]로 교체. IP 수집 오류 처리를 nil 반환에서 빈 배열 반환으로 변경. 최종 IP 추출 로직을 단일 선택값 구성에서 배열 필터링 및 매핑으로 업데이트.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 네트워크의 길을 따라가며
여러 주소를 모아 모아
배열 속에 정렬하니
인터페이스들 춤을 춘다
IP들의 새로운 향연! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive 풀 리퀘스트 설명이 제공되지 않았습니다. 변경 사항에 대한 설명, 이유, 그리고 테스트 방법을 포함한 풀 리퀘스트 설명을 추가해주세요.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 주요 변경 사항을 명확하게 요약하고 있습니다. fetchIP 함수가 인터페이스 타입과 함께 IP 목록을 반환하도록 변경된 것이 정확히 반영되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/fetch_ip_list

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@minjae999 minjae999 self-assigned this Feb 11, 2026
@minjae999 minjae999 merged commit e3f01a7 into main Feb 11, 2026
1 of 3 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 32-35: The InterfaceType struct is declared public but its
properties name and family are implicitly internal, preventing external access
(e.g., IP.interfaceType.name); update the property access control by making both
properties public so they are accessible from other modules—modify InterfaceType
to declare public let name: String and public let family: sa_family_t while
keeping the struct public.
- Around line 95-99: The returned IP array uses ipStorage.filter which iterates
a Dictionary and thus loses the priority order defined by searchs; change the
logic to iterate searchs in order and for each key lookup ipStorage[key],
building the result with searchs.map/compactMap so the resulting [IP] preserves
the desired priority (e.g., en0 → pdp_ip0 → utun0); update the code that
constructs IP(ip: value, interfaceType: key) to be produced from the ordered
lookup instead of filtering the dictionary.

Comment on lines +32 to +35
public struct InterfaceType: Hashable {
let name: String
let family: sa_family_t
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

InterfaceType 속성의 접근 제어자가 누락되었습니다.

public struct이지만 namefamily 속성에 접근 제어자가 없어 기본값인 internal이 적용됩니다. 외부 모듈에서 IP.interfaceType.name이나 IP.interfaceType.family에 접근할 수 없게 됩니다.

🔧 접근 제어자 추가 제안
 public struct InterfaceType: Hashable {
-    let name: String
-    let family: sa_family_t
+    public let name: String
+    public let family: sa_family_t
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public struct InterfaceType: Hashable {
let name: String
let family: sa_family_t
}
public struct InterfaceType: Hashable {
public let name: String
public let family: sa_family_t
}
🤖 Prompt for AI Agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 32 - 35, The
InterfaceType struct is declared public but its properties name and family are
implicitly internal, preventing external access (e.g., IP.interfaceType.name);
update the property access control by making both properties public so they are
accessible from other modules—modify InterfaceType to declare public let name:
String and public let family: sa_family_t while keeping the struct public.

Comment on lines +95 to 99
return ipStorage
.filter { searchs.contains($0.key) }
.map { key, value in
IP(ip: value, interfaceType: key)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

반환되는 IP 배열의 순서가 보장되지 않습니다.

Dictionary의 iteration 순서는 Swift에서 보장되지 않습니다. searchs 배열이 우선순위 순서(en0 → pdp_ip0 → utun0)를 정의하고 있지만, 현재 구현은 이 순서를 보존하지 않습니다.

🔧 순서 보장을 위한 수정 제안
-        return ipStorage
-            .filter { searchs.contains($0.key) }
-            .map { key, value in
-                IP(ip: value, interfaceType: key)
-            }
+        return searchs.compactMap { interfaceType in
+            guard let ip = ipStorage[interfaceType] else { return nil }
+            return IP(ip: ip, interfaceType: interfaceType)
+        }
🤖 Prompt for AI Agents
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 95 - 99, The
returned IP array uses ipStorage.filter which iterates a Dictionary and thus
loses the priority order defined by searchs; change the logic to iterate searchs
in order and for each key lookup ipStorage[key], building the result with
searchs.map/compactMap so the resulting [IP] preserves the desired priority
(e.g., en0 → pdp_ip0 → utun0); update the code that constructs IP(ip: value,
interfaceType: key) to be produced from the ordered lookup instead of filtering
the dictionary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants