Skip to content

Feature/fetch ip list#24

Merged
minjae999 merged 8 commits intomainfrom
feature/fetch_ip_list
Feb 23, 2026
Merged

Feature/fetch ip list#24
minjae999 merged 8 commits intomainfrom
feature/fetch_ip_list

Conversation

@minjae999
Copy link
Contributor

No description provided.

@minjae999 minjae999 requested a review from pokeum February 11, 2026 06:14
@minjae999 minjae999 self-assigned this Feb 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

NetworkFetcher의 공개 API가 InterfaceType에서 새 공개 IP 타입(address, interface, 중첩 IP.Version(v4/v6))으로 교체되었고, 내부 저장소와 IP 수집/필터링 로직이 이에 맞춰 평면화된 [IP] 형태로 변경되었습니다.

Changes

Cohort / File(s) Summary
공개 API 타입 변경
Source/AppleFetcher/Implement/NetworkFetcher.swift
public struct InterfaceType 제거. 대신 public struct IP { public let address: String; public let interface: String; public let version: IP.Version }IP.Version(v4, v6) 추가 — 공개 시그니처가 변경됨.
내부 저장소/타입 변경
Source/AppleFetcher/Implement/NetworkFetcher.swift
내부 저장소가 기존의 [InterfaceType: String] 매핑에서 평면화된 [IP] 배열(ipList)로 변경됨 — 기존 키 기반 접근 제거.
수집·필터링 로직 업데이트
Source/AppleFetcher/Implement/NetworkFetcher.swift
fetch 로직이 sa_family_t 대신 AF_INET/AF_INET6로부터 IP.Version을 유도하고 getnameinfo 결과를 옵셔널로 처리. 특정 인터페이스 이름(en0, pdp_ip0, utun0)으로 필터링하며 잘못된 주소/가족 값은 건너뜀. 반환 타입은 [IP].

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 새 IP가 반짝반짝, 주소와 인터페이스 들고
v4·v6로 깡충깡충, 한 줄 배열로 뛰어다녀요
필터는 단순히 이름만 보고, 잘못된 건 슬쩍 건너뛰죠
당근 축하춤, 코드도 경쾌히 폴짝! 🥕✨

🚥 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 No pull request description was provided by the author; cannot assess whether the description relates to the changeset. Add a description explaining the motivation and impact of replacing InterfaceType with the new IP struct and Version enum.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title references fetching IP list functionality, which matches the core changes to IP fetching logic and structure in NetworkFetcher.swift.

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

✨ Finishing Touches
🧪 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

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

@minjae999 minjae999 requested review from gignac-cha and removed request for pokeum February 19, 2026 03:09
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: 1

🧹 Nitpick comments (1)
Source/AppleFetcher/Implement/NetworkFetcher.swift (1)

70-81: 즉시 실행 클로저(IIFE) 패턴 단순화 제안

현재 로직은 정확하지만, 즉시 실행 클로저 대신 computed property 스타일이나 별도 함수로 추출하면 가독성이 향상될 수 있습니다.

♻️ 선택적 리팩토링 제안
             let family = interface.ifa_addr.pointee.sa_family
-            guard let protocolVersion = {
-                switch Int32(family) {
-                case AF_INET:
-                    return InterfaceType.ProtocolVersion.v4
-                case AF_INET6:
-                    return InterfaceType.ProtocolVersion.v6
-                default:
-                    return nil
-                }
-            }()
-            else { continue }
+            let protocolVersion: InterfaceType.ProtocolVersion
+            switch Int32(family) {
+            case AF_INET:
+                protocolVersion = .v4
+            case AF_INET6:
+                protocolVersion = .v6
+            default:
+                continue
+            }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 70 - 81, The
inline immediately-invoked closure computing protocolVersion from
interface.ifa_addr.pointee.sa_family is unnecessary; replace it with a small
helper (e.g., a static/function like protocolVersion(forFamily: Int32) ->
InterfaceType.ProtocolVersion?) or a computed property that switches on the
family and returns .v4, .v6 or nil, then call that helper to produce
protocolVersion and guard-let it (referring to
interface.ifa_addr.pointee.sa_family, family, and InterfaceType.ProtocolVersion
in the replacement).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 106-113: Rename the misspelled variable searchs to searches in
NetworkFetcher.swift and update all references to it (e.g., any later uses
around where InterfaceType list is consumed) so the new identifier is
consistent; ensure variable declaration at InterfaceType(...) array and every
subsequent access (such as the usage mentioned near the later block) are updated
to the new name to avoid compile errors.

---

Nitpick comments:
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 70-81: The inline immediately-invoked closure computing
protocolVersion from interface.ifa_addr.pointee.sa_family is unnecessary;
replace it with a small helper (e.g., a static/function like
protocolVersion(forFamily: Int32) -> InterfaceType.ProtocolVersion?) or a
computed property that switches on the family and returns .v4, .v6 or nil, then
call that helper to produce protocolVersion and guard-let it (referring to
interface.ifa_addr.pointee.sa_family, family, and InterfaceType.ProtocolVersion
in the replacement).

@minjae999 minjae999 requested a review from 0xWOF February 19, 2026 07:11
This change flattens the IP struct by removing the InterfaceType wrapper and directly embedding interface name and protocol version as properties. This simplifies the data structure and reduces nesting while maintaining the same functionality.

fix: correct typo in variable name 'searchs' to 'searches'
@minjae999 minjae999 force-pushed the feature/fetch_ip_list branch from d3babc4 to cb065e3 Compare February 19, 2026 07:12
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 53-55: ipStorage currently uses the interface name as the sole key
so IPv4 and IPv6 entries overwrite each other; change the storage to include the
IP version (for example make ipStorage a dictionary keyed by (interfaceName,
IP.Version) or a nested [String: [IP.Version: String]]) and update the code
paths that write/read ipStorage (the code using the ipStorage variable and the
loop that iterates over searches) so each interface can hold both v4 and v6
addresses without clobbering; keep interfacesPointer usage unchanged but ensure
insertion uses the new key shape and any lookups (later code that reads
ipStorage) are updated to account for the versioned key.
- Around line 65-76: The code dereferences interface.ifa_addr directly which can
be nil and crash; in the protocolVersion determination (the closure using
interface.ifa_addr.pointee.sa_family) add a guard let addr = interface.ifa_addr
to early-skip when nil, then use addr.pointee.sa_family (reusing the
non-optional pointer) to map AF_INET/AF_INET6 to IP.Version.v4/v6; apply the
same nil-check and pointer reuse to the similar block around lines 78-89 to
avoid crashes when ifa_addr is nil.

- Simplify ipStorage structure to use IP objects directly instead of tuples
- Rename interfaceType to interfaceName for clarity
- Streamline searches array by removing redundant version specifications
- Simplify filtering logic by removing unnecessary map operations
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.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 65-76: The code dereferences interface.ifa_addr without nil-check
causing possible crashes; update the logic in the guard computing
protocolVersion (and the subsequent getnameinfo call) to safely optional-bind
interface.ifa_addr (e.g., guard let addrPtr = interface.ifa_addr else { continue
}), use addrPtr.pointee.sa_family when switching to determine IP.Version (in
protocolVersion) and unwrap the sockaddr pointer before passing to getnameinfo
so both the family/switch and the getnameinfo invocation skip interfaces with
nil ifa_addr rather than force-dereferencing.
- Line 53: ipStorage currently uses only the interface name as the key (var
ipStorage: [String: IP]) so IPv4 and IPv6 for the same interface overwrite each
other; update the storage to distinguish address families by either using a
composite key (e.g., interface + family) or change ipStorage to a nested
structure or array (e.g., [String: [IPFamily: IP]] or [String: [IP]]) and update
any code that writes/reads ipStorage in NetworkFetcher.swift (references:
ipStorage variable and the assignment logic around the same file, including the
code near line 93) to store and retrieve both v4 and v6 entries without
clobbering.

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Source/AppleFetcher/Implement/NetworkFetcher.swift (1)

53-108: ⚠️ Potential issue | 🔴 Critical

freeifaddrs 이중 호출로 double free 가능성이 있습니다.

Line 56의 defer로 해제한 뒤 Line 106에서 다시 호출되어 크래시 위험이 있습니다. 하나만 유지하세요.

🛠️ 수정 제안
-        freeifaddrs(interfacesPointer)
-
         return ipList
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Source/AppleFetcher/Implement/NetworkFetcher.swift` around lines 53 - 108,
The code calls freeifaddrs twice causing a potential double-free: remove the
explicit freeifaddrs(interfacesPointer) at the end and rely on the existing
defer { freeifaddrs(interfacesPointer) } that is declared next to
interfacesPointer; ensure interfacesPointer is still declared as var
interfacesPointer: UnsafeMutablePointer<ifaddrs>? and that
getifaddrs(&interfacesPointer) and the sequence loop (using
interfaceFirstPointer) remain unchanged so cleanup happens exactly once.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@Source/AppleFetcher/Implement/NetworkFetcher.swift`:
- Around line 53-108: The code calls freeifaddrs twice causing a potential
double-free: remove the explicit freeifaddrs(interfacesPointer) at the end and
rely on the existing defer { freeifaddrs(interfacesPointer) } that is declared
next to interfacesPointer; ensure interfacesPointer is still declared as var
interfacesPointer: UnsafeMutablePointer<ifaddrs>? and that
getifaddrs(&interfacesPointer) and the sequence loop (using
interfaceFirstPointer) remain unchanged so cleanup happens exactly once.

- Fix whitespace in guard statement
- Remove unnecessary freeifaddrs call
The defer statement was being executed even if getifaddrs failed,
potentially calling freeifaddrs on an uninitialized pointer.
@minjae999 minjae999 merged commit 0bfc4a9 into main Feb 23, 2026
2 of 3 checks passed
@minjae999 minjae999 deleted the feature/fetch_ip_list branch February 23, 2026 01:00
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