Skip to content

Commit

Permalink
Changed default port to 8000
Browse files Browse the repository at this point in the history
* The default port has been changed from 80 to 8000, to avoid the
  use of a restricted port.

* The documentation has been updated to reflect the same.
  • Loading branch information
nandahkrishna committed Jun 7, 2020
1 parent bb9a339 commit 04dac06
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 29 deletions.
18 changes: 14 additions & 4 deletions PIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ PyPI: https://pypi.org/project/Airshare <br>

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install Airshare.
* Install using `pip`

```bash
$ pip install Airshare
```

If you have a non-Apple device, consider installing Avahi (for Linux) or Bonjour (for Windows) if you'd like to use Link-local Name Resolution (for the `.local` addresses).
* Install using `pipx`

```bash
$ pipx install Airshare
```

* Install using Homebrew

```bash
$ brew install airshare
```

## Example

Expand All @@ -60,15 +70,15 @@ To receive using the CLI,
$ airshare noobmaster
```

or visit `http://noobmaster.local` in the browser to download.
or visit `http://noobmaster.local:8000` in the browser to download.

You can also `import airshare` in any Python program. Visit the documentation for detailed usage instructions.

## Known Issues

* Link-local Name Resolution (for the `.local` addresses) on non-Apple devices requires Avahi (on Linux) or Bonjour (on Windows). Chances are you already have them, but if you don't, do check the web on how to install them.

* Link-local Name Resolution does not work on Android phones. This is because Android browsers do not have inbuilt Multicast-DNS service discovery. For this reason, we included QR Code support, for you to visit the URLs easily.
* Android browsers do not have inbuilt Multicast-DNS service discovery, and cannot resolve the `.local` addresses. For this reason, we included QR Code support, for you to visit the URLs easily.

* Windows users with Python < 3.8, use <kbd>Ctrl</kbd> + <kbd>Break</kbd> to quit, as <kbd>Ctrl</kbd> + <kbd>C</kbd> will not work. This is a known issue with `asyncio`, which has been fixed in Python 3.8. If you do not have a <kbd>Break</kbd> key, try using <kbd>Ctrl</kbd> + <kbd>Fn</kbd> + <kbd>B</kbd>, or check the web for other alternatives (depending on your PC).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ To receive using the CLI,
$ airshare noobmaster
```

or visit `http://noobmaster.local` in the browser to download.
or visit `http://noobmaster.local:8000` in the browser to download.

You can also `import airshare` in any Python program. Visit the documentation for detailed usage instructions.

Expand Down
4 changes: 2 additions & 2 deletions airshare/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

@click.command(name="airshare")
@click.argument("code", nargs=1)
@click.option("-p", "--port", type=int, default=80, help="""
Specify the port number to host a sending or receiving server (defaults to 80).
@click.option("-p", "--port", type=int, default=8000, help="""
Specify the port number to host a sending or receiving server (default 8000).
""")
@click.option("-t", "--text", type=str, help="""
Send (serve) text content. For multiple words, enclose within quotes.
Expand Down
8 changes: 4 additions & 4 deletions airshare/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, code):

def __str__(self):
return "CodeExistsError: The Airshare `" + self.code \
+ ".local` already exists!"
+ "` already exists!"


class CodeNotFoundError(AirshareError):
Expand All @@ -34,7 +34,7 @@ def __init__(self, code):

def __str__(self):
return "CodeNotFoundError: The Airshare `" + self.code \
+ ".local` was not found!"
+ "` was not found!"


class IsNotReceiverError(AirshareError):
Expand All @@ -48,7 +48,7 @@ def __init__(self, code):

def __str__(self):
return "IsNotReceiverError: The Airshare `" + self.code \
+ ".local` is not an Upload Receiver!"
+ "` is not an Upload Receiver!"


class IsNotSenderError(AirshareError):
Expand All @@ -62,4 +62,4 @@ def __init__(self, code):

def __str__(self):
return "IsNotSenderError: The Airshare `" + self.code \
+ ".local` is not a Text or File Sender!"
+ "` is not a Text or File Sender!"
10 changes: 5 additions & 5 deletions airshare/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def receive(*, code, decompress=False):
airshare_type = requests.get(url + "/airshare").text
if "Sender" not in airshare_type:
raise IsNotSenderError(code)
print("Receiving from Airshare `" + code + ".local`...")
print("Receiving from Airshare `" + code + "`...")
sleep(2)
if airshare_type == "Text Sender":
text = requests.get(url + "/text").text
Expand Down Expand Up @@ -145,7 +145,7 @@ def receive(*, code, decompress=False):
return file_path


def receive_server(*, code, decompress=False, port=80):
def receive_server(*, code, decompress=False, port=8000):
r"""Serves a file receiver and registers it as a Multicast-DNS service.
Parameters
Expand All @@ -154,7 +154,7 @@ def receive_server(*, code, decompress=False, port=80):
Identifying code for the Airshare service and server.
decompress : boolean, default=False
Flag to enable or disable decompression (Zip).
port : int, default=80
port : int, default=8000
Port number at which the server is hosted on the device.
"""
info = get_service_info(code)
Expand Down Expand Up @@ -191,7 +191,7 @@ def receive_server(*, code, decompress=False, port=80):
loop.run_forever()


def receive_server_proc(*, code, decompress=False, port=80):
def receive_server_proc(*, code, decompress=False, port=8000):
r"""Creates a process with 'receive_server' as the target.
Parameters
Expand All @@ -200,7 +200,7 @@ def receive_server_proc(*, code, decompress=False, port=80):
Identifying code for the Airshare service and server.
decompress : boolean, default=False
Flag to enable or disable decompression (Zip).
port : int, default=80
port : int, default=8000
Port number at which the server is hosted on the device.
Returns
Expand Down
10 changes: 5 additions & 5 deletions airshare/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ def send(*, code, file, compress=False):
m = MultipartEncoder(fields={"field0": (name, open(file, "rb"))})
headers = {"content-type": m.content_type, "airshare-compress": compress}
r = requests.post(url + "/upload", data=m, headers=headers)
print("Uploaded `" + name + "` to Airshare `" + code + ".local`!")
print("Uploaded `" + name + "` to Airshare `" + code + "`!")
return r.status_code


def send_server(*, code, text=None, file=None, compress=False, port=80):
def send_server(*, code, text=None, file=None, compress=False, port=8000):
r"""Serves a file or text and registers it as a Multicast-DNS service.
Parameters
Expand All @@ -161,7 +161,7 @@ def send_server(*, code, text=None, file=None, compress=False, port=80):
compress : boolean, default=False
Flag to enable or disable compression (Zip).
Effective when only one file is given.
port : int, default=80
port : int, default=8000
Port number at which the server is hosted on the device.
"""
info = get_service_info(code)
Expand Down Expand Up @@ -227,7 +227,7 @@ def send_server(*, code, text=None, file=None, compress=False, port=80):
loop.run_forever()


def send_server_proc(*, code, text=None, file=None, compress=False, port=80):
def send_server_proc(*, code, text=None, file=None, compress=False, port=8000):
r"""Creates a process with 'send_server' as the target.
Parameters
Expand All @@ -246,7 +246,7 @@ def send_server_proc(*, code, text=None, file=None, compress=False, port=80):
compress : boolean, default=False
Flag to enable or disable compression (Zip).
Effective when only one file is given.
port : int, default=80
port : int, default=8000
Port number at which the server is hosted on the device.
Returns
Expand Down
4 changes: 2 additions & 2 deletions docs/source/_static/cli_usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Usage: airshare [OPTIONS] CODE [FILES]
Options:

-p, --port INTEGER Specify the port number to host a sending or receiving
server (defaults to 80).
server (default 8000).

-t, --text TEXT Send (serve) text content. For multiple words, enclose
within quotes.
Expand All @@ -26,4 +26,4 @@ Options:

--help Show this message and exit.

--version Show the version and exit.
--version Show the version and exit.
20 changes: 14 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,23 @@ Important Links
Installation
------------

Use the package manager `pip <https://pip.pypa.io/en/stable/>`__ to
install Airshare.
* Installation using ``pip``

.. code:: bash
$ pip install Airshare
If you have a non-Apple device, consider installing Avahi (for Linux) or Bonjour (for Windows) if you'd like to use Link-local Name Resolution (for the ``.local`` addresses).
* Installation using ``pipx``

.. code:: bash
$ pipx install Airshare
* Installation using Homebrew

.. code:: bash
$ brew install airshare
CLI Tool Reference
------------------
Expand Down Expand Up @@ -106,14 +115,13 @@ Known Issues
------------

* Link-local Name Resolution (for the ``.local`` addresses) on non-Apple devices requires Avahi (on Linux) or Bonjour (on Windows). Chances are you already have them, but if you don't, do check the web on how to install them.
* Link-local Name Resolution does not work on Android phones. This is because Android browsers do not have inbuilt Multicast-DNS service discovery. For this reason, we included QR Code support, for you to visit the URLs easily.
* Android browsers do not have inbuilt Multicast-DNS service discovery, and cannot resolve the ``.local`` addresses. For this reason, we included QR Code support, for you to visit the URLs easily.
* Windows users with Python < 3.8, use ``Ctrl`` + ``Break`` to quit, as ``Ctrl`` + ``C`` will not work. This is a known issue with ``asyncio``, which has been fixed in Python 3.8. If you do not have a ``Break`` key, try using ``Ctrl`` + ``Fn`` + ``B``, or check the web for other alternatives (depending on your PC).

Contributing
------------

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.
Pull requests are welcome. Read our `Contribution Guide <https://github.com/KuroLabs/Airshare/blob/master/CONTRIBUTING.md>`__ for more details.

License
-------
Expand Down

0 comments on commit 04dac06

Please sign in to comment.