Compare commits
	
		
			1 Commits
		
	
	
		
			master
			...
			2b315d17ea
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2b315d17ea | 
							
								
								
									
										43
									
								
								.github/workflows/docker.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										43
									
								
								.github/workflows/docker.yml
									
									
									
									
										vendored
									
									
								
							@@ -1,43 +0,0 @@
 | 
				
			|||||||
name: Create and publish Docker images for tagged versions
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
on:
 | 
					 | 
				
			||||||
  push:
 | 
					 | 
				
			||||||
    tags:
 | 
					 | 
				
			||||||
      - 'v*'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
env:
 | 
					 | 
				
			||||||
  REGISTRY: ghcr.io
 | 
					 | 
				
			||||||
  IMAGE_NAME: ${{ github.repository }}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
jobs:
 | 
					 | 
				
			||||||
  build-docker-image:
 | 
					 | 
				
			||||||
    runs-on: ubuntu-latest
 | 
					 | 
				
			||||||
    permissions:
 | 
					 | 
				
			||||||
      contents: write
 | 
					 | 
				
			||||||
      packages: write
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    steps:
 | 
					 | 
				
			||||||
      - name: Check out repository
 | 
					 | 
				
			||||||
        uses: actions/checkout@v3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Log into GHCR
 | 
					 | 
				
			||||||
        if: github.event_name != 'pull_request'
 | 
					 | 
				
			||||||
        uses: docker/login-action@v2
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          registry: ${{ env.REGISTRY }}
 | 
					 | 
				
			||||||
          username: ${{ github.actor }}
 | 
					 | 
				
			||||||
          password: ${{ secrets.GITHUB_TOKEN }}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Extract Docker metadata
 | 
					 | 
				
			||||||
        id: meta
 | 
					 | 
				
			||||||
        uses: docker/metadata-action@v4
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      - name: Build and push Docker image
 | 
					 | 
				
			||||||
        uses: docker/build-push-action@v3
 | 
					 | 
				
			||||||
        with:
 | 
					 | 
				
			||||||
          context: .
 | 
					 | 
				
			||||||
          push: ${{ github.event_name != 'pull_request' }}
 | 
					 | 
				
			||||||
          tags: ${{ steps.meta.outputs.tags }}
 | 
					 | 
				
			||||||
          labels: ${{ steps.meta.output.labels }}
 | 
					 | 
				
			||||||
							
								
								
									
										21
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,18 +1,5 @@
 | 
				
			|||||||
FROM python:3-slim
 | 
					FROM docker.io/library/python:3-alpine
 | 
				
			||||||
 | 
					 | 
				
			||||||
LABEL org.opencontainers.image.description='Unwebsockify is a TCP to WebSocket proxy/bridge -- like a reverse websockify.' \
 | 
					 | 
				
			||||||
      org.opencontainers.image.source='https://github.com/jimparis/unwebsockify' \
 | 
					 | 
				
			||||||
      org.opencontainers.image.licenses='MIT'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
 | 
					 | 
				
			||||||
    PYTHONFAULTHANDLER=1 \
 | 
					 | 
				
			||||||
    PYTHONHASHSEED=random \
 | 
					 | 
				
			||||||
    PYTHONUNBUFFERED=1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
WORKDIR /usr/src/app
 | 
					WORKDIR /usr/src/app
 | 
				
			||||||
 | 
					RUN pip install --no-cache-dir websockets
 | 
				
			||||||
COPY requirements.txt .
 | 
					COPY unwebsockify.py ./
 | 
				
			||||||
RUN pip install --no-cache-dir -r requirements.txt
 | 
					ENTRYPOINT [ "python", "-u", "./unwebsockify.py" ]
 | 
				
			||||||
 | 
					 | 
				
			||||||
COPY unwebsockify.py .
 | 
					 | 
				
			||||||
ENTRYPOINT [ "python", "./unwebsockify.py" ]
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										19
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								LICENSE
									
									
									
									
									
								
							@@ -1,19 +0,0 @@
 | 
				
			|||||||
Copyright (C) 2021 Jim Paris <jim@jim.sh>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					 | 
				
			||||||
of this software and associated documentation files (the "Software"), to deal
 | 
					 | 
				
			||||||
in the Software without restriction, including without limitation the rights
 | 
					 | 
				
			||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					 | 
				
			||||||
copies of the Software, and to permit persons to whom the Software is
 | 
					 | 
				
			||||||
furnished to do so, subject to the following conditions:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
The above copyright notice and this permission notice shall be included in all
 | 
					 | 
				
			||||||
copies or substantial portions of the Software.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
					 | 
				
			||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
					 | 
				
			||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
					 | 
				
			||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					 | 
				
			||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					 | 
				
			||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
					 | 
				
			||||||
SOFTWARE.
 | 
					 | 
				
			||||||
@@ -7,8 +7,7 @@ essentially the opposite of
 | 
				
			|||||||
Note that this only handles simple byte streams of data, with no
 | 
					Note that this only handles simple byte streams of data, with no
 | 
				
			||||||
support for conveying WebSockets message framing back to the client.
 | 
					support for conveying WebSockets message framing back to the client.
 | 
				
			||||||
In most cases, **specifying the WebSockets subprotocol (via
 | 
					In most cases, **specifying the WebSockets subprotocol (via
 | 
				
			||||||
`--subproto`) is necessary**, because the server expects it to match
 | 
					`--subproto`) is necessary**, because the server requires it.
 | 
				
			||||||
some particular string.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Install dependencies
 | 
					# Install dependencies
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,7 @@ class Proxy:
 | 
				
			|||||||
    async def handle_client(self, r, w):
 | 
					    async def handle_client(self, r, w):
 | 
				
			||||||
        peer = w.get_extra_info("peername")
 | 
					        peer = w.get_extra_info("peername")
 | 
				
			||||||
        print(f'{peer} connected')
 | 
					        print(f'{peer} connected')
 | 
				
			||||||
        loop = asyncio.get_running_loop()
 | 
					        loop = asyncio.get_event_loop()
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            async with websockets.connect(
 | 
					            async with websockets.connect(
 | 
				
			||||||
                    self.url, subprotocols=self.subproto) as ws:
 | 
					                    self.url, subprotocols=self.subproto) as ws:
 | 
				
			||||||
@@ -96,8 +96,7 @@ def main(argv):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    args = parser.parse_args()
 | 
					    args = parser.parse_args()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    loop = asyncio.new_event_loop()
 | 
					    loop = asyncio.get_event_loop()
 | 
				
			||||||
    asyncio.set_event_loop(loop)
 | 
					 | 
				
			||||||
    proxy = Proxy(args.port, args.listen, args.url, args.subproto)
 | 
					    proxy = Proxy(args.port, args.listen, args.url, args.subproto)
 | 
				
			||||||
    loop.run_until_complete(proxy.start())
 | 
					    loop.run_until_complete(proxy.start())
 | 
				
			||||||
    loop.run_forever()
 | 
					    loop.run_forever()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user