flwr-nightly 1.16.0.dev20250220__py3-none-any.whl → 1.16.0.dev20250225__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flwr/common/address.py +35 -0
- {flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/METADATA +1 -1
- {flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/RECORD +6 -6
- {flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/LICENSE +0 -0
- {flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/WHEEL +0 -0
- {flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/entry_points.txt +0 -0
flwr/common/address.py
CHANGED
@@ -15,10 +15,13 @@
|
|
15
15
|
"""Flower IP address utils."""
|
16
16
|
|
17
17
|
|
18
|
+
import re
|
18
19
|
import socket
|
19
20
|
from ipaddress import ip_address
|
20
21
|
from typing import Optional
|
21
22
|
|
23
|
+
import grpc
|
24
|
+
|
22
25
|
IPV6: int = 6
|
23
26
|
|
24
27
|
|
@@ -101,3 +104,35 @@ def is_port_in_use(address: str) -> bool:
|
|
101
104
|
return True
|
102
105
|
|
103
106
|
return False
|
107
|
+
|
108
|
+
|
109
|
+
def get_ip_address_from_servicer_context(context: grpc.ServicerContext) -> str:
|
110
|
+
"""Extract the client's IPv4 or IPv6 address from the gRPC ServicerContext.
|
111
|
+
|
112
|
+
Parameters
|
113
|
+
----------
|
114
|
+
context : grpc.ServicerContext
|
115
|
+
The gRPC ServicerContext object. The context.peer() returns a string like
|
116
|
+
"ipv4:127.0.0.1:56789" for IPv4 and "ipv6:[2001:db8::1]:54321" for IPv6.
|
117
|
+
|
118
|
+
Returns
|
119
|
+
-------
|
120
|
+
str
|
121
|
+
If one of the format matches, the function will return the client's IP address,
|
122
|
+
otherwise, it will raise a ValueError.
|
123
|
+
"""
|
124
|
+
peer: str = context.peer()
|
125
|
+
# Match IPv4: "ipv4:IP:port"
|
126
|
+
ipv4_match = re.match(r"^ipv4:(?P<ip>[^:]+):", peer)
|
127
|
+
if ipv4_match:
|
128
|
+
return ipv4_match.group("ip")
|
129
|
+
|
130
|
+
# Match IPv6: "ipv6:[IP]:port"
|
131
|
+
ipv6_match = re.match(r"^ipv6:\[(?P<ip>[^\]]+)\]:", peer)
|
132
|
+
if ipv6_match:
|
133
|
+
return ipv6_match.group("ip")
|
134
|
+
|
135
|
+
raise ValueError(
|
136
|
+
f"Unsupported peer address format: {peer} for the transport protocol. "
|
137
|
+
"The supported formats are ipv4:IP:port and ipv6:[IP]:port."
|
138
|
+
)
|
{flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/RECORD
RENAMED
@@ -112,7 +112,7 @@ flwr/client/supernode/__init__.py,sha256=SUhWOzcgXRNXk1V9UgB5-FaWukqqrOEajVUHEcP
|
|
112
112
|
flwr/client/supernode/app.py,sha256=oBbggh56HoieksBkTdDHAJC8VUFbrmGOP0-D9wdcZek,9265
|
113
113
|
flwr/client/typing.py,sha256=dxoTBnTMfqXr5J7G3y-uNjqxYCddvxhu89spfj4Lm2U,1048
|
114
114
|
flwr/common/__init__.py,sha256=TVaoFEJE158aui1TPZQiJCDZX4RNHRyI8I55VC80HhI,3901
|
115
|
-
flwr/common/address.py,sha256=
|
115
|
+
flwr/common/address.py,sha256=rRaN1JpiCJnit7ImEqZVxURQ69dPihRoyyWn_3I2wh4,4119
|
116
116
|
flwr/common/args.py,sha256=MgkTUXACuySHyNdxrb7-pK0_R-S2Q7W5MnE3onYUf5I,5183
|
117
117
|
flwr/common/auth_plugin/__init__.py,sha256=1Y8Oj3iB49IHDu9tvDih1J74Ygu7k85V9s2A4WORPyA,887
|
118
118
|
flwr/common/auth_plugin/auth_plugin.py,sha256=wgDorBUB4IkK6twQ8vNawRVz7BDPmKdXZBNLqhU9RSs,3871
|
@@ -327,8 +327,8 @@ flwr/superexec/exec_servicer.py,sha256=X10ILT-AoGMrB3IgI2mBe9i-QcIVUAl9bucuqVOPY
|
|
327
327
|
flwr/superexec/exec_user_auth_interceptor.py,sha256=K06OU-l4LnYhTDg071hGJuOaQWEJbZsYi5qxUmmtiG0,3704
|
328
328
|
flwr/superexec/executor.py,sha256=_B55WW2TD1fBINpabSSDRenVHXYmvlfhv-k8hJKU4lQ,3115
|
329
329
|
flwr/superexec/simulation.py,sha256=WQDon15oqpMopAZnwRZoTICYCfHqtkvFSqiTQ2hLD_g,4088
|
330
|
-
flwr_nightly-1.16.0.
|
331
|
-
flwr_nightly-1.16.0.
|
332
|
-
flwr_nightly-1.16.0.
|
333
|
-
flwr_nightly-1.16.0.
|
334
|
-
flwr_nightly-1.16.0.
|
330
|
+
flwr_nightly-1.16.0.dev20250225.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
331
|
+
flwr_nightly-1.16.0.dev20250225.dist-info/METADATA,sha256=Sh3iV8qd0cS526-IF2D_U0_Lj5KJkCbzwiwtFLzVrkw,15877
|
332
|
+
flwr_nightly-1.16.0.dev20250225.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
333
|
+
flwr_nightly-1.16.0.dev20250225.dist-info/entry_points.txt,sha256=JlNxX3qhaV18_2yj5a3kJW1ESxm31cal9iS_N_pf1Rk,538
|
334
|
+
flwr_nightly-1.16.0.dev20250225.dist-info/RECORD,,
|
{flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/LICENSE
RENAMED
File without changes
|
{flwr_nightly-1.16.0.dev20250220.dist-info → flwr_nightly-1.16.0.dev20250225.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|