MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / setup_bridge_macos

Method setup_bridge_macos

avp_stream/bridge_avp.py:136–172  ·  view source on GitHub ↗

Set up bridge on macOS.

(self)

Source from the content-addressed store, hash-verified

134 self.bridge_ip = "169.254.220.1" # Use .1 as the host IP
135
136 def setup_bridge_macos(self):
137 """Set up bridge on macOS."""
138 print("\nSetting up bridge...")
139
140 # 1. Enable IP forwarding
141 print(" • Enabling IP forwarding...")
142 self.run_command(["sudo", "sysctl", "-w", "net.inet.ip.forwarding=1"], capture=False)
143
144 # 2. Configure bridge0
145 print(" • Configuring bridge0...")
146 self.run_command([
147 "sudo", "ifconfig", "bridge0", "inet", self.bridge_ip,
148 "netmask", "255.255.255.0"
149 ], capture=False)
150 subprocess.run(["sleep", "1"])
151
152 # 3. Add primary interface to bridge0
153 print(f" • Adding {self.primary_interface} to bridge0...")
154 self.run_command([
155 "sudo", "ifconfig", "bridge0", "addm", self.primary_interface
156 ], check=False, capture=False)
157 subprocess.run(["sleep", "2"])
158
159 # 4. Set up NAT
160 print(" • Configuring NAT...")
161 # Enable pfctl
162 self.run_command(["sudo", "pfctl", "-e"], check=False, capture=False)
163
164 # Create NAT rule
165 nat_rule = f"nat on {self.primary_interface} inet from bridge0:network to any -> ({self.primary_interface})"
166 proc = subprocess.Popen(
167 ["sudo", "pfctl", "-f", "-"],
168 stdin=subprocess.PIPE,
169 stderr=subprocess.DEVNULL
170 )
171 proc.communicate(input=nat_rule.encode())
172 subprocess.run(["sleep", "2"])
173
174 def setup_bridge_linux(self):
175 """Set up bridge on Linux.

Callers 1

setupMethod · 0.95

Calls 3

run_commandMethod · 0.95
runMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected