gnutella 1.0.0
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.
- package/CLI.md +189 -0
- package/DEVELOPER.md +193 -0
- package/LICENSE +674 -0
- package/QUICKSTART.md +133 -0
- package/README.md +74 -0
- package/bin/gnutella.ts +15 -0
- package/gnutella.json.example +18 -0
- package/package.json +72 -0
- package/src/cli.ts +692 -0
- package/src/cli_shared.ts +359 -0
- package/src/const.ts +138 -0
- package/src/gwebcache/bootstrap.ts +491 -0
- package/src/gwebcache/response.ts +391 -0
- package/src/gwebcache/shared.ts +116 -0
- package/src/gwebcache/types.ts +187 -0
- package/src/gwebcache_client.ts +13 -0
- package/src/protocol/browse_host.ts +552 -0
- package/src/protocol/client_blocking.ts +29 -0
- package/src/protocol/codec.ts +715 -0
- package/src/protocol/content_urn.ts +170 -0
- package/src/protocol/core_utils.ts +43 -0
- package/src/protocol/file_server.ts +245 -0
- package/src/protocol/ggep.ts +168 -0
- package/src/protocol/handshake.ts +199 -0
- package/src/protocol/http_download_reader.ts +112 -0
- package/src/protocol/magnet.ts +176 -0
- package/src/protocol/node.ts +416 -0
- package/src/protocol/node_handshake.ts +992 -0
- package/src/protocol/node_lifecycle.ts +210 -0
- package/src/protocol/node_protocol_runtime.ts +949 -0
- package/src/protocol/node_qrp_runtime.ts +97 -0
- package/src/protocol/node_query_routing.ts +208 -0
- package/src/protocol/node_state.ts +745 -0
- package/src/protocol/node_tls.ts +257 -0
- package/src/protocol/node_topology.ts +141 -0
- package/src/protocol/node_transfer.ts +455 -0
- package/src/protocol/node_types.ts +106 -0
- package/src/protocol/peer_state.ts +675 -0
- package/src/protocol/qrp.ts +549 -0
- package/src/protocol/query_search.ts +29 -0
- package/src/protocol/share_index.ts +131 -0
- package/src/protocol/share_library.ts +246 -0
- package/src/protocol.ts +36 -0
- package/src/shared.ts +236 -0
- package/src/types.ts +452 -0
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Quickstart
|
|
2
|
+
|
|
3
|
+
This guide gets you from zero to a working CLI session with sharing, searching, browsing, and downloading.
|
|
4
|
+
|
|
5
|
+
## 1. Get GnutellaBun
|
|
6
|
+
|
|
7
|
+
You can either:
|
|
8
|
+
|
|
9
|
+
- download a prebuilt binary from the [releases page](https://github.com/RickCarlino/gnutella-bun-client/releases)
|
|
10
|
+
- run from source with Bun
|
|
11
|
+
|
|
12
|
+
If you are running from source:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Throughout this guide, commands use the CLI command:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
gnutella
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If you are running from source, replace `gnutella` with:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun run bin/gnutella.ts
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
If you are using a compiled binary, replace `gnutella` with the executable path.
|
|
31
|
+
|
|
32
|
+
## 2. Create A Config
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
gnutella init --config gnutella.json
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This creates a config file and a downloads folder.
|
|
39
|
+
|
|
40
|
+
By default, GnutellaBun shares files from `./downloads` and also saves downloaded files there.
|
|
41
|
+
|
|
42
|
+
## 3. Put Files In Your Share Folder
|
|
43
|
+
|
|
44
|
+
Copy any files you want to share into `./downloads`.
|
|
45
|
+
|
|
46
|
+
If you changed `config.data_dir`, use `<data_dir>/downloads` instead.
|
|
47
|
+
|
|
48
|
+
## 4. Start The Client
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
gnutella run --config gnutella.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
GnutellaBun will try to bootstrap on its own. If you already know a peer and want to connect to it directly, you can still use `connect <ip:port>` after startup.
|
|
55
|
+
|
|
56
|
+
Useful first commands:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
status
|
|
60
|
+
peers
|
|
61
|
+
shares
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 5. Search For Files
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
query hello world
|
|
68
|
+
results
|
|
69
|
+
info 1
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`results` gives you numbered hits.
|
|
73
|
+
|
|
74
|
+
`info 1` shows the details for result `1`.
|
|
75
|
+
|
|
76
|
+
If you want a magnet link for a result:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
magnet 1
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 6. Browse A Host
|
|
83
|
+
|
|
84
|
+
If a peer looks interesting, you can browse its whole shared library.
|
|
85
|
+
|
|
86
|
+
First list your connected peers:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
peers
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Then browse by peer key:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
browse p1
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can also browse directly by address:
|
|
99
|
+
|
|
100
|
+
```text
|
|
101
|
+
browse 203.0.113.10:6346
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 7. Download A Result
|
|
105
|
+
|
|
106
|
+
Download to the default folder:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
download 1
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Or pick an explicit destination:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
download 1 ./my-copy.bin
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
If the destination file already exists, GnutellaBun resumes from the current file size when possible.
|
|
119
|
+
|
|
120
|
+
## 8. Save And Quit
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
save
|
|
124
|
+
quit
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`save` writes the current config and remembered peers to disk right away.
|
|
128
|
+
|
|
129
|
+
## If Something Looks Empty
|
|
130
|
+
|
|
131
|
+
- No peers yet: give bootstrap a little time, or run `connect <ip:port>` if you already know a live peer.
|
|
132
|
+
- No results yet: wait a few seconds after connecting, then try another query.
|
|
133
|
+
- Want the full command list and config reference: read [CLI.md](CLI.md).
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# GnutellaBun
|
|
2
|
+
|
|
3
|
+
GnutellaBun is a small Bun-based Gnutella client you can run from the terminal or embed in a TypeScript app.
|
|
4
|
+
|
|
5
|
+
It is built for people who want to:
|
|
6
|
+
|
|
7
|
+
- share files from one folder
|
|
8
|
+
- search the Gnutella network
|
|
9
|
+
- inspect results before downloading
|
|
10
|
+
- browse another peer's shared library
|
|
11
|
+
- keep useful state across restarts
|
|
12
|
+
|
|
13
|
+
It can be used in three ways:
|
|
14
|
+
|
|
15
|
+
- as an interactive CLI
|
|
16
|
+
- as a scripted CLI runner
|
|
17
|
+
- as a library inside another app
|
|
18
|
+
|
|
19
|
+
It interoperates with other Gnutella clients, including GTK Gnutella.
|
|
20
|
+
|
|
21
|
+
## Prebuilt Binaries
|
|
22
|
+
|
|
23
|
+
- [Windows](https://github.com/RickCarlino/gnutella-bun-client/releases/latest/download/gnutella-bun-windows-x64.exe)
|
|
24
|
+
- [Windows (older CPUs)](https://github.com/RickCarlino/gnutella-bun-client/releases/latest/download/gnutella-bun-windows-x64-baseline.exe)
|
|
25
|
+
- [macOS Intel](https://github.com/RickCarlino/gnutella-bun-client/releases/latest/download/gnutella-bun-darwin-x64)
|
|
26
|
+
- [macOS Apple Silicon](https://github.com/RickCarlino/gnutella-bun-client/releases/latest/download/gnutella-bun-darwin-arm64)
|
|
27
|
+
- [Linux builds](https://github.com/RickCarlino/gnutella-bun-client/releases)
|
|
28
|
+
- [All releases](https://github.com/RickCarlino/gnutella-bun-client/releases)
|
|
29
|
+
|
|
30
|
+
Download a prebuilt executable from the [releases page](https://github.com/RickCarlino/gnutella-bun-client/releases).
|
|
31
|
+
|
|
32
|
+
After downloading, run the executable directly:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
./gnutella-bun-linux-x64 init --config gnutella.json
|
|
36
|
+
./gnutella-bun-linux-x64 run --config gnutella.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## From Source
|
|
40
|
+
|
|
41
|
+
If you want to run from source:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
bun install
|
|
45
|
+
bun run bin/gnutella.ts init --config gnutella.json
|
|
46
|
+
bun run bin/gnutella.ts run --config gnutella.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Library Use
|
|
50
|
+
|
|
51
|
+
**NOTE:** Node support is not done. Use Bun.
|
|
52
|
+
|
|
53
|
+
When used from this repository, the public TypeScript import is:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { GnutellaServent, loadDoc } from "gnutella";
|
|
57
|
+
|
|
58
|
+
const configPath = "./gnutella.json";
|
|
59
|
+
const doc = await loadDoc(configPath);
|
|
60
|
+
const node = new GnutellaServent(configPath, doc);
|
|
61
|
+
|
|
62
|
+
await node.start();
|
|
63
|
+
node.sendQuery("hello world");
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Guides
|
|
67
|
+
|
|
68
|
+
- [Quickstart](QUICKSTART.md): get the CLI working in a few minutes
|
|
69
|
+
- [CLI Guide](CLI.md): full command and config reference
|
|
70
|
+
- [Developer Guide](DEVELOPER.md): embed GnutellaBun in your own TypeScript app
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
GnutellaBun is released under the GNU General Public License v3.0. See [LICENSE](LICENSE).
|
package/bin/gnutella.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
|
|
5
|
+
import { errMsg } from "../src/cli_shared";
|
|
6
|
+
import { main as modernMain } from "../src/cli";
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
await modernMain(process.argv.slice(2));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
main().catch((e) => {
|
|
13
|
+
console.error(errMsg(e));
|
|
14
|
+
process.exit(1);
|
|
15
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"config": {
|
|
3
|
+
"listen_ip": "0.0.0.0",
|
|
4
|
+
"listen_port": 22867,
|
|
5
|
+
"blocked_ips": [],
|
|
6
|
+
"ultrapeer": false,
|
|
7
|
+
"max_ultrapeer_connections": 64,
|
|
8
|
+
"max_leaf_connections": 64,
|
|
9
|
+
"log_ignore": [],
|
|
10
|
+
"data_dir": "."
|
|
11
|
+
},
|
|
12
|
+
"state": {
|
|
13
|
+
"servent_id_hex": "00112233445566778899aabbccddeeff",
|
|
14
|
+
"peers": {
|
|
15
|
+
"127.0.0.1:22867": 0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gnutella",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GnutellaBun is a small Gnutella client for Bun, usable as a CLI or TypeScript library.",
|
|
5
|
+
"license": "GPL-3.0-only",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gnutella": "./bin/gnutella.ts"
|
|
8
|
+
},
|
|
9
|
+
"main": "./src/protocol.ts",
|
|
10
|
+
"types": "./src/protocol.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": "./src/protocol.ts",
|
|
13
|
+
"./types": "./src/types.ts",
|
|
14
|
+
"./gwebcache": "./src/gwebcache_client.ts"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin",
|
|
18
|
+
"src",
|
|
19
|
+
"README.md",
|
|
20
|
+
"QUICKSTART.md",
|
|
21
|
+
"CLI.md",
|
|
22
|
+
"DEVELOPER.md",
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"gnutella.json.example"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"bun": ">=1.3.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"gnutella",
|
|
31
|
+
"p2p",
|
|
32
|
+
"peer-to-peer",
|
|
33
|
+
"bun",
|
|
34
|
+
"cli"
|
|
35
|
+
],
|
|
36
|
+
"homepage": "https://github.com/RickCarlino/gnutella-bun-client#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/RickCarlino/gnutella-bun-client/issues"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/RickCarlino/gnutella-bun-client.git"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": "bun@1.3.11",
|
|
45
|
+
"dependencies": {},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@babel/core": "^7.27.1",
|
|
48
|
+
"@babel/eslint-parser": "^7.27.1",
|
|
49
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
50
|
+
"@types/node": "^25.5.0",
|
|
51
|
+
"bun-types": "^1.3.11",
|
|
52
|
+
"eslint": "^9.24.0",
|
|
53
|
+
"jscpd": "^4.0.8",
|
|
54
|
+
"prettier": "^3.5.3",
|
|
55
|
+
"ts-unused-exports": "^11.0.1",
|
|
56
|
+
"typescript": "^6.0.2"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build:all": "./scripts/build-all-targets.sh",
|
|
60
|
+
"dupcheck": "jscpd",
|
|
61
|
+
"format:check": "prettier --check AGENTS.md README.md bin package.json tsconfig.json gnutella.json.example src tests scripts --ignore-unknown",
|
|
62
|
+
"format:write": "prettier --write AGENTS.md README.md bin package.json tsconfig.json gnutella.json.example src tests scripts --ignore-unknown",
|
|
63
|
+
"lint": "eslint bin src tests --ext .ts",
|
|
64
|
+
"test": "bun test",
|
|
65
|
+
"test:integration": "bun test tests/integration/protocol.test.ts",
|
|
66
|
+
"test:unit": "bun test tests/unit",
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
68
|
+
"unused-exports": "ts-unused-exports tsconfig.json --excludePathsFromReport=src/protocol.ts --exitWithCount",
|
|
69
|
+
"fix": "./scripts/fix-all.sh",
|
|
70
|
+
"verify": "./scripts/verify-all.sh"
|
|
71
|
+
}
|
|
72
|
+
}
|