Skip to content

Commit 4be1985

Browse files
authored
Merge pull request #16 from icgood/bind
Fix the default bind hostname
2 parents 4ae65fb + 88b8683 commit 4be1985

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ FROM python:3.8-alpine
33
RUN pip install -U pip wheel setuptools typing-extensions
44

55
ARG install_arg="proxy-protocol"
6+
ARG install_source=""
67
RUN apk --update add --virtual build-dependencies python3-dev build-base \
7-
&& pip install ${install_arg} \
8+
&& pip install "${install_arg}${install_source}" \
89
&& apk del build-dependencies
910

1011
ENTRYPOINT ["proxyprotocol-server"]

docker/hooks/build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -ex
33

4-
export install_arg="$GITHUB_REPO/archive/$SOURCE_BRANCH.tar.gz"
5-
docker build --build-arg install_arg -f $DOCKERFILE_PATH -t $IMAGE_NAME .
4+
export install_source=" @ $GITHUB_REPO/archive/$SOURCE_BRANCH.tar.gz"
5+
docker build --build-arg install_source -f $DOCKERFILE_PATH -t $IMAGE_NAME .

proxyprotocol/server/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Address:
2222
2323
"""
2424

25-
def __init__(self, addr: str, *, server: bool) -> None:
25+
def __init__(self, addr: str, *, server: bool = False) -> None:
2626
super().__init__()
2727
url = urlsplit(addr)
2828
if not url.scheme and not url.netloc:
@@ -39,7 +39,7 @@ def __init__(self, addr: str, *, server: bool) -> None:
3939
@property
4040
def host(self) -> str:
4141
"""The hostname parsed from the address."""
42-
return self.url.hostname or 'localhost'
42+
return self.url.hostname or ''
4343

4444
@property
4545
def port(self) -> Optional[int]:

proxyprotocol/server/echo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def main() -> int:
2828
help='the PROXY protocol version')
2929
parser.add_argument('address', metavar='HOST:PORT',
3030
type=partial(Address, server=True),
31-
nargs='?', default='localhost:10007',
31+
nargs='?', default=':10007',
3232
help='the listener address')
3333
args = parser.parse_args()
3434

@@ -44,7 +44,7 @@ async def run(pp: ProxyProtocol, address: Address) -> int:
4444
loop = asyncio.get_event_loop()
4545
callback = partial(run_conn, pp)
4646
server = await asyncio.start_server(
47-
callback, address.host, address.port or 10007, ssl=address.ssl)
47+
callback, address.host, address.port or 0, ssl=address.ssl)
4848
async with server:
4949
forever = asyncio.create_task(server.serve_forever())
5050
loop.add_signal_handler(signal.SIGINT, forever.cancel)

proxyprotocol/server/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main() -> int:
5050

5151
async def run(pp: ProxyProtocol, args: Namespace) -> int:
5252
loop = asyncio.get_running_loop()
53-
services = [(Address(source, server=True), Address(dest, server=False))
53+
services = [(Address(source, server=True), Address(dest))
5454
for (source, dest) in args.services]
5555
buf_len: int = args.buf_len
5656
new_server = partial(DownstreamProtocol, UpstreamProtocol,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
license = f.read()
2929

3030
setup(name='proxy-protocol',
31-
version='0.5.5',
31+
version='0.5.6',
3232
author='Ian Good',
3333
author_email='ian@icgood.net',
3434
description='PROXY protocol library with asyncio server implementation',

0 commit comments

Comments
 (0)