Creates a tunnel that forwards traffic from the host to a service. Parameters ---------- service: Service to send traffic from the tunnel. native: Map each service port to the same port on the host, as if the service were running n
(
self,
service: "Service",
*,
native: bool | None = False,
ports: list[PortForward] | None = None,
)
| 10169 | return Service(_ctx) |
| 10170 | |
| 10171 | def tunnel( |
| 10172 | self, |
| 10173 | service: "Service", |
| 10174 | *, |
| 10175 | native: bool | None = False, |
| 10176 | ports: list[PortForward] | None = None, |
| 10177 | ) -> "Service": |
| 10178 | """Creates a tunnel that forwards traffic from the host to a service. |
| 10179 | |
| 10180 | Parameters |
| 10181 | ---------- |
| 10182 | service: |
| 10183 | Service to send traffic from the tunnel. |
| 10184 | native: |
| 10185 | Map each service port to the same port on the host, as if the |
| 10186 | service were running natively. |
| 10187 | Note: enabling may result in port conflicts. |
| 10188 | ports: |
| 10189 | Configure explicit port forwarding rules for the tunnel. |
| 10190 | If a port's frontend is unspecified or 0, a random port will be |
| 10191 | chosen by the host. |
| 10192 | If no ports are given, all of the service's ports are forwarded. |
| 10193 | If native is true, each port maps to the same port on the host. If |
| 10194 | native is false, each port maps to a random port chosen by the |
| 10195 | host. |
| 10196 | If ports are given and native is true, the ports are additive. |
| 10197 | """ |
| 10198 | _args = [ |
| 10199 | Arg("service", service), |
| 10200 | Arg("native", native, False), |
| 10201 | Arg("ports", [] if ports is None else ports, []), |
| 10202 | ] |
| 10203 | _ctx = self._select("tunnel", _args) |
| 10204 | return Service(_ctx) |
| 10205 | |
| 10206 | def unix_socket(self, path: str) -> "Socket": |
| 10207 | """Accesses a Unix socket on the host. |