bitbang 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bitbang-0.1.0/LICENSE +21 -0
- bitbang-0.1.0/PKG-INFO +16 -0
- bitbang-0.1.0/README.md +147 -0
- bitbang-0.1.0/bitbang/__init__.py +11 -0
- bitbang-0.1.0/bitbang/__main__.py +20 -0
- bitbang-0.1.0/bitbang/adapter.py +837 -0
- bitbang-0.1.0/bitbang/apps/fileshare/core.py +76 -0
- bitbang-0.1.0/bitbang/apps/fileshare/flask_app.py +281 -0
- bitbang-0.1.0/bitbang/apps/webcam/bitbangflask.py +63 -0
- bitbang-0.1.0/bitbang/apps/webcam/flask_app.py +18 -0
- bitbang-0.1.0/bitbang/examples/simple_fastapi/runapp.py +18 -0
- bitbang-0.1.0/bitbang/examples/simple_flask/runapp.py +13 -0
- bitbang-0.1.0/bitbang/identity.py +222 -0
- bitbang-0.1.0/bitbang.egg-info/PKG-INFO +16 -0
- bitbang-0.1.0/bitbang.egg-info/SOURCES.txt +20 -0
- bitbang-0.1.0/bitbang.egg-info/dependency_links.txt +1 -0
- bitbang-0.1.0/bitbang.egg-info/entry_points.txt +3 -0
- bitbang-0.1.0/bitbang.egg-info/requires.txt +12 -0
- bitbang-0.1.0/bitbang.egg-info/top_level.txt +1 -0
- bitbang-0.1.0/pyproject.toml +28 -0
- bitbang-0.1.0/setup.cfg +4 -0
- bitbang-0.1.0/setup.py +3 -0
bitbang-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rich LeGrand
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
bitbang-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bitbang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Connect browsers to devices via WebRTC
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: aiortc
|
|
8
|
+
Requires-Dist: websockets
|
|
9
|
+
Requires-Dist: flask
|
|
10
|
+
Requires-Dist: cryptography>=3.4
|
|
11
|
+
Requires-Dist: qrcode>=7.0
|
|
12
|
+
Requires-Dist: tomli>=1.0; python_version < "3.11"
|
|
13
|
+
Provides-Extra: fastapi
|
|
14
|
+
Requires-Dist: fastapi; extra == "fastapi"
|
|
15
|
+
Requires-Dist: uvicorn; extra == "fastapi"
|
|
16
|
+
Dynamic: license-file
|
bitbang-0.1.0/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# BitBang
|
|
2
|
+
|
|
3
|
+
BitBang exposes local web servers to the internet using WebRTC peer-to-peer connections. No account required, no monthly fee, no data routed through third-party servers.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
pip install bitbang
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick demo
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bitbang-fileshare ~/Downloads
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This prints a URL and QR code. Anyone with the link can browse and download files directly from your machine. To verify it works outside your local network, scan the QR code from a phone on cellular.
|
|
16
|
+
|
|
17
|
+
## Flask / FastAPI integration
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
# Flask
|
|
21
|
+
app = Flask(__name__)
|
|
22
|
+
adapter = BitBangWSGI(app)
|
|
23
|
+
adapter.run() # Prints your public URL
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
# FastAPI
|
|
28
|
+
app = FastAPI()
|
|
29
|
+
adapter = BitBangASGI(app)
|
|
30
|
+
adapter.run()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Comparison
|
|
34
|
+
|
|
35
|
+
| | ngrok | Cloudflare Tunnel | Tailscale | BitBang |
|
|
36
|
+
|---|---|---|---|---|
|
|
37
|
+
| Account required | Yes | Yes | Yes | No |
|
|
38
|
+
| Free tunnels | 1 | Unlimited | Unlimited | Unlimited |
|
|
39
|
+
| Data path | Their servers | Their servers | P2P | P2P |
|
|
40
|
+
| Viewer needs install | No | No | Yes | No |
|
|
41
|
+
| Configuration | CLI flags | Config file + DNS | Dashboard | None |
|
|
42
|
+
|
|
43
|
+
BitBang's data path is direct between peers. The signaling server brokers the initial connection, then steps aside.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Background
|
|
48
|
+
|
|
49
|
+
The Internet is often thought of as a fully connected network — every machine is accessible from every other machine. But there are rules governing accessibility on the Internet.
|
|
50
|
+
|
|
51
|
+
### Rules of Internet Accessibility
|
|
52
|
+
|
|
53
|
+
1. Machines on the Internet are accessible by other machines on the Internet — and by machines on your local network.
|
|
54
|
+
2. Machines on your local network are only accessible by other machines on your local network.
|
|
55
|
+
|
|
56
|
+
Because of rule 2, machines on your local network aren't reachable from outside — nor are the resources they hold: files, cameras, sensors, compute, or the web app you're currently developing. Cloud services exist to fill this gap: Dropbox for files, AWS IoT for sensors, Tailscale for compute, and ngrok for web apps — among others. These services apply rule 1, but each comes with the friction of account creation, monthly charges, and your data living on someone else's server.
|
|
57
|
+
|
|
58
|
+
BitBang connects a browser directly to any machine on your local network, from anywhere on the Internet. No cloud intermediary, no account, no third party in the middle. It uses a novel application of the peer-to-peer technology WebRTC.
|
|
59
|
+
|
|
60
|
+
### WebRTC
|
|
61
|
+
|
|
62
|
+
WebRTC is the behind-the-scenes technology that makes Zoom and Google Meet video conferencing possible. WebRTC offers the highest bandwidth and lowest latency possible, which is important when you're streaming live video. It's mature, well-tested, and has ubiquitous support across all browsers. In addition to delivering low-latency media, it can also deliver raw data over "data channels", which is what BitBang uses.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
The `examples/` directory contains two simple demos:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cd examples/simple_fastapi && python3 runapp.py
|
|
72
|
+
cd examples/simple_flask && python3 runapp.py
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Each prints a URL like `https://bitba.ng/6a1ccd1516a0ead5bd25c46b0bff14b3`, accessible from anywhere.
|
|
76
|
+
|
|
77
|
+
## Fileshare
|
|
78
|
+
|
|
79
|
+
Share files without uploading them to a third-party service:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
bitbang-fileshare photo.jpg # Share a single file
|
|
83
|
+
bitbang-fileshare ~/Documents/project # Share a directory (uploads enabled)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Files transfer directly from your machine to the recipient.
|
|
87
|
+
|
|
88
|
+
## Webcam
|
|
89
|
+
|
|
90
|
+
The `webcam` app streams video to your browser using WebRTC media channels. It can be used as a simple easy-to-setup monitoring/security camera using your laptop, for example.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
bitbang-webcam
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## How it works
|
|
99
|
+
|
|
100
|
+
Browsers normally connect to web servers over TCP. BitBang replaces this with a WebRTC data channel:
|
|
101
|
+
|
|
102
|
+

|
|
103
|
+
|
|
104
|
+
The signaling server (`bitba.ng`) brokers the WebRTC handshake, then has no further involvement. It never sees application data.
|
|
105
|
+
|
|
106
|
+
## Signaling server
|
|
107
|
+
|
|
108
|
+
The signaling server source is available [here](https://github.com/richlegrand/bitbang-server). It:
|
|
109
|
+
|
|
110
|
+
1. Serves the BitBang browser runtime
|
|
111
|
+
2. Validates connecting servers via RSA challenge
|
|
112
|
+
3. Maintains WebSocket connections to active servers
|
|
113
|
+
4. Brokers ICE candidate and SDP exchange
|
|
114
|
+
|
|
115
|
+
After the P2P connection is established, the signaling server is not involved.
|
|
116
|
+
|
|
117
|
+
## Security
|
|
118
|
+
|
|
119
|
+
WebRTC mandates encryption:
|
|
120
|
+
|
|
121
|
+
- **Data channels**: DTLS 1.2+
|
|
122
|
+
- **Media streams**: SRTP
|
|
123
|
+
- **Signaling**: HTTPS and WSS
|
|
124
|
+
|
|
125
|
+
Furthermore, each BitBang server generates an RSA keypair. The public key hash becomes its unique ID, which is used in its BitBang public URL. The signaling server challenge-verifies key ownership before accepting connections.
|
|
126
|
+
|
|
127
|
+
## Roadmap
|
|
128
|
+
|
|
129
|
+
**proxybang** — A standalone binary that proxies any server on the local network. Run it once; the target is specified in the URL at browse-time.
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
https://bitban.ng/<proxy-id>/192.168.1.10:80
|
|
133
|
+
https://bitban.ng/<proxy-id>/nas.local
|
|
134
|
+
https://bitban.ng/<proxy-id>/octopi.local:5000
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**ESP32 support** — Native BitBang for microcontrollers, including video streaming and OTA updates. It's an IoT network with no account set-up, subscription, etc.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
Issues and pull requests are welcome.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# bitbang/__main__.py
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
def main():
|
|
5
|
+
if len(sys.argv) < 2:
|
|
6
|
+
print("Usage: python -m bitbang <command>")
|
|
7
|
+
print("Commands: webcam, files, send")
|
|
8
|
+
sys.exit(1)
|
|
9
|
+
|
|
10
|
+
cmd = sys.argv[1]
|
|
11
|
+
if cmd == "webcam":
|
|
12
|
+
from bitbang.examples.webcam import run
|
|
13
|
+
run()
|
|
14
|
+
elif cmd == "send":
|
|
15
|
+
from bitbang.examples.send import run
|
|
16
|
+
run()
|
|
17
|
+
# etc
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
main()
|