@howdoi-cli/networking 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/LICENSE +21 -0
- package/README.md +34 -0
- package/data/networking/curl.yaml +57 -0
- package/data/networking/dig.yaml +35 -0
- package/data/networking/ping.yaml +21 -0
- package/data/networking/ss.yaml +35 -0
- package/package.json +35 -0
- package/postinstall.mjs +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 howdoi-cli contributors
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @howdoi-cli/networking
|
|
2
|
+
|
|
3
|
+
**howdoi knowledge base — networking commands.**
|
|
4
|
+
|
|
5
|
+
Part of the [howdoi](https://github.com/SiphoChris/howdoi-cli) ecosystem.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @howdoi-cli/networking
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This also installs `@howdoi-cli/core` (the engine and `howdoi` binary) automatically.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
howdoi <what you want to do>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install more knowledge bases
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g @howdoi-cli/unix
|
|
25
|
+
npm install -g @howdoi-cli/git
|
|
26
|
+
npm install -g @howdoi-cli/ssh
|
|
27
|
+
npm install -g @howdoi-cli/docker
|
|
28
|
+
npm install -g @howdoi-cli/networking
|
|
29
|
+
npm install -g @howdoi-cli/all
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
tool: curl
|
|
2
|
+
category: networking
|
|
3
|
+
description: Transfer data to and from servers
|
|
4
|
+
package: "@howdoi-cli/networking"
|
|
5
|
+
intents:
|
|
6
|
+
- make http request
|
|
7
|
+
- send get request
|
|
8
|
+
- send post request
|
|
9
|
+
- send json data
|
|
10
|
+
- post json to api
|
|
11
|
+
- add headers to request
|
|
12
|
+
- download file with curl
|
|
13
|
+
- follow redirects
|
|
14
|
+
- send form data
|
|
15
|
+
- test api endpoint
|
|
16
|
+
- check http response code
|
|
17
|
+
- send delete request
|
|
18
|
+
- send put request
|
|
19
|
+
- authenticate with curl
|
|
20
|
+
- pass bearer token
|
|
21
|
+
examples:
|
|
22
|
+
- intent: send get request
|
|
23
|
+
title: Simple GET request
|
|
24
|
+
command: curl https://api.example.com/users
|
|
25
|
+
- intent: send get request
|
|
26
|
+
title: GET request with pretty output
|
|
27
|
+
command: curl -s https://api.example.com/users | python3 -m json.tool
|
|
28
|
+
- intent: send post request
|
|
29
|
+
title: POST request with JSON body
|
|
30
|
+
command: curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d '{"name":"Sipho"}'
|
|
31
|
+
- intent: post json to api
|
|
32
|
+
title: POST JSON from a file
|
|
33
|
+
command: curl -X POST https://api.example.com/users -H "Content-Type: application/json" -d @payload.json
|
|
34
|
+
- intent: add headers to request
|
|
35
|
+
title: Add custom headers to a request
|
|
36
|
+
command: curl -H "Authorization: Bearer TOKEN" -H "Accept: application/json" https://api.example.com
|
|
37
|
+
- intent: pass bearer token
|
|
38
|
+
title: Authenticate with a Bearer token
|
|
39
|
+
command: curl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com/protected
|
|
40
|
+
- intent: download file with curl
|
|
41
|
+
title: Download a file and save it
|
|
42
|
+
command: curl -o filename.zip https://example.com/file.zip
|
|
43
|
+
- intent: download file with curl
|
|
44
|
+
title: Download and keep the original filename
|
|
45
|
+
command: curl -O https://example.com/file.zip
|
|
46
|
+
- intent: check http response code
|
|
47
|
+
title: Show only the HTTP status code
|
|
48
|
+
command: curl -s -o /dev/null -w "%{http_code}" https://example.com
|
|
49
|
+
- intent: follow redirects
|
|
50
|
+
title: Follow HTTP redirects automatically
|
|
51
|
+
command: curl -L https://example.com
|
|
52
|
+
- intent: send delete request
|
|
53
|
+
title: Send a DELETE request
|
|
54
|
+
command: curl -X DELETE https://api.example.com/users/123
|
|
55
|
+
- intent: send put request
|
|
56
|
+
title: Send a PUT request with JSON
|
|
57
|
+
command: curl -X PUT https://api.example.com/users/123 -H "Content-Type: application/json" -d '{"name":"Updated"}'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
tool: dig
|
|
2
|
+
category: networking
|
|
3
|
+
description: DNS lookup and query tool
|
|
4
|
+
package: "@howdoi-cli/networking"
|
|
5
|
+
intents:
|
|
6
|
+
- lookup dns record
|
|
7
|
+
- check dns for domain
|
|
8
|
+
- find ip address of domain
|
|
9
|
+
- check mx record
|
|
10
|
+
- check nameservers
|
|
11
|
+
- lookup txt record
|
|
12
|
+
- reverse dns lookup
|
|
13
|
+
- query specific dns server
|
|
14
|
+
examples:
|
|
15
|
+
- intent: find ip address of domain
|
|
16
|
+
title: Look up the A record for a domain
|
|
17
|
+
command: dig google.com
|
|
18
|
+
- intent: find ip address of domain
|
|
19
|
+
title: Short answer only
|
|
20
|
+
command: dig +short google.com
|
|
21
|
+
- intent: check mx record
|
|
22
|
+
title: Look up MX (mail) records
|
|
23
|
+
command: dig MX google.com
|
|
24
|
+
- intent: check nameservers
|
|
25
|
+
title: Look up NS records
|
|
26
|
+
command: dig NS google.com
|
|
27
|
+
- intent: lookup txt record
|
|
28
|
+
title: Look up TXT records (SPF, verification etc.)
|
|
29
|
+
command: dig TXT google.com
|
|
30
|
+
- intent: reverse dns lookup
|
|
31
|
+
title: Reverse DNS lookup from IP address
|
|
32
|
+
command: dig -x 8.8.8.8
|
|
33
|
+
- intent: query specific dns server
|
|
34
|
+
title: Query a specific DNS server
|
|
35
|
+
command: dig @8.8.8.8 google.com
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
tool: ping
|
|
2
|
+
category: networking
|
|
3
|
+
description: Test network connectivity to a host
|
|
4
|
+
package: "@howdoi-cli/networking"
|
|
5
|
+
intents:
|
|
6
|
+
- test network connection
|
|
7
|
+
- check if host is reachable
|
|
8
|
+
- ping a server
|
|
9
|
+
- check network latency
|
|
10
|
+
- test internet connection
|
|
11
|
+
examples:
|
|
12
|
+
- intent: ping a server
|
|
13
|
+
title: Ping a host
|
|
14
|
+
command: ping google.com
|
|
15
|
+
- intent: test network connection
|
|
16
|
+
title: Ping a limited number of times
|
|
17
|
+
command: ping -c 4 google.com
|
|
18
|
+
- intent: check network latency
|
|
19
|
+
title: Ping with timestamps
|
|
20
|
+
command: ping -D google.com
|
|
21
|
+
os: linux-only
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
tool: ss
|
|
2
|
+
category: networking
|
|
3
|
+
description: Inspect network sockets and connections (modern netstat)
|
|
4
|
+
package: "@howdoi-cli/networking"
|
|
5
|
+
intents:
|
|
6
|
+
- check open ports
|
|
7
|
+
- see listening ports
|
|
8
|
+
- find what is using a port
|
|
9
|
+
- list network connections
|
|
10
|
+
- check port in use
|
|
11
|
+
- see active connections
|
|
12
|
+
- find process using port
|
|
13
|
+
examples:
|
|
14
|
+
- intent: see listening ports
|
|
15
|
+
title: Show all listening ports
|
|
16
|
+
command: ss -tlnp
|
|
17
|
+
- intent: see listening ports
|
|
18
|
+
title: Show listening ports (netstat fallback)
|
|
19
|
+
command: netstat -tlnp
|
|
20
|
+
os: linux-only
|
|
21
|
+
- intent: check open ports
|
|
22
|
+
title: Show all open ports (TCP and UDP)
|
|
23
|
+
command: ss -tulnp
|
|
24
|
+
- intent: find what is using a port
|
|
25
|
+
title: Find what process is using port 3000
|
|
26
|
+
command: ss -tlnp | grep :3000
|
|
27
|
+
- intent: find process using port
|
|
28
|
+
title: Find process using a port with lsof
|
|
29
|
+
command: lsof -i :3000
|
|
30
|
+
- intent: list network connections
|
|
31
|
+
title: Show all established connections
|
|
32
|
+
command: ss -tnp state established
|
|
33
|
+
- intent: check port in use
|
|
34
|
+
title: Check if a specific port is open on a remote host
|
|
35
|
+
command: nc -zv hostname 3000
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@howdoi-cli/networking",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Networking knowledge base for howdoi — curl, netstat, ping, dig, and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"data",
|
|
8
|
+
"postinstall.mjs",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "node postinstall.mjs",
|
|
14
|
+
"publish:npm": "npm publish"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"howdoi": {
|
|
20
|
+
"type": "knowledge-base",
|
|
21
|
+
"dataDir": "data"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@howdoi-cli/core": "^1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": ["cli", "networking", "curl", "terminal", "howdoi"],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/SiphoChris/howdoi-cli"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, mkdirSync, existsSync, readFileSync } from "fs";
|
|
3
|
+
import { join, dirname, resolve } from "path";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
|
|
6
|
+
// process.argv[1] is always the path of the running script — reliable across
|
|
7
|
+
// all package managers and working directories
|
|
8
|
+
const scriptDir = dirname(resolve(process.argv[1]));
|
|
9
|
+
const pkgJsonPath = join(scriptDir, "package.json");
|
|
10
|
+
|
|
11
|
+
if (!existsSync(pkgJsonPath)) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
16
|
+
const pkgName = pkgJson.name.replace("@howdoi-cli/", "");
|
|
17
|
+
|
|
18
|
+
// Skip in monorepo dev context — check for workspace root two levels up
|
|
19
|
+
const monoRootPkg = resolve(scriptDir, "..", "..", "package.json");
|
|
20
|
+
if (existsSync(monoRootPkg)) {
|
|
21
|
+
try {
|
|
22
|
+
const root = JSON.parse(readFileSync(monoRootPkg, "utf-8"));
|
|
23
|
+
if (root.workspaces) {
|
|
24
|
+
console.log(`[howdoi] Dev mode — skipping XDG install for ${pkgJson.name}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
} catch { /* continue */ }
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const srcData = join(scriptDir, "data");
|
|
31
|
+
if (!existsSync(srcData)) {
|
|
32
|
+
process.exit(0);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const xdgBase = process.env.XDG_DATA_HOME ?? join(homedir(), ".local", "share");
|
|
36
|
+
const dest = join(xdgBase, "howdoi", pkgName);
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
mkdirSync(dest, { recursive: true });
|
|
40
|
+
cpSync(srcData, dest, { recursive: true });
|
|
41
|
+
console.log(`[howdoi] ✓ ${pkgJson.name}@${pkgJson.version} → ${dest}`);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.warn(`[howdoi] Warning: could not copy data: ${err.message}`);
|
|
44
|
+
console.warn(`[howdoi] howdoi will still work via node_modules fallback.`);
|
|
45
|
+
}
|