@fuman/net 0.0.11 → 0.0.15
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/ip/bundle.cjs +2 -0
- package/ip/bundle.d.cts +1 -0
- package/ip/bundle.d.ts +1 -0
- package/ip/bundle.js +2 -0
- package/ip/prettify.cjs +18 -0
- package/ip/prettify.d.cts +10 -0
- package/ip/prettify.d.ts +10 -0
- package/ip/prettify.js +18 -0
- package/package.json +3 -3
- package/proxy/http/connect.d.cts +1 -1
- package/proxy/http/connect.d.ts +1 -1
package/ip/bundle.cjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const parse = require("./parse.cjs");
|
|
4
|
+
const prettify = require("./prettify.cjs");
|
|
4
5
|
const v4 = require("./v4.cjs");
|
|
5
6
|
const v6 = require("./v6.cjs");
|
|
6
7
|
exports.parse = parse.parse;
|
|
7
8
|
exports.parseWithPort = parse.parseWithPort;
|
|
8
9
|
exports.stringify = parse.stringify;
|
|
9
10
|
exports.stringifyWithPort = parse.stringifyWithPort;
|
|
11
|
+
exports.prettify = prettify.prettify;
|
|
10
12
|
exports.normalizeV4 = v4.normalizeV4;
|
|
11
13
|
exports.parseV4 = v4.parseV4;
|
|
12
14
|
exports.stringifyV4 = v4.stringifyV4;
|
package/ip/bundle.d.cts
CHANGED
package/ip/bundle.d.ts
CHANGED
package/ip/bundle.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parse, parseWithPort, stringify, stringifyWithPort } from "./parse.js";
|
|
2
|
+
import { prettify } from "./prettify.js";
|
|
2
3
|
import { normalizeV4, parseV4, stringifyV4 } from "./v4.js";
|
|
3
4
|
import { expandV6, fromBytesV6, parseV6, readV6, stringifyV6, toBytesV6, writeV6 } from "./v6.js";
|
|
4
5
|
export {
|
|
@@ -9,6 +10,7 @@ export {
|
|
|
9
10
|
parseV4,
|
|
10
11
|
parseV6,
|
|
11
12
|
parseWithPort,
|
|
13
|
+
prettify,
|
|
12
14
|
readV6,
|
|
13
15
|
stringify,
|
|
14
16
|
stringifyV4,
|
package/ip/prettify.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
function prettify(address, options) {
|
|
4
|
+
const {
|
|
5
|
+
encloseIpv6 = false
|
|
6
|
+
} = options || {};
|
|
7
|
+
const isIpv6 = address.includes(":");
|
|
8
|
+
if (isIpv6) {
|
|
9
|
+
address = `[${address}]`;
|
|
10
|
+
}
|
|
11
|
+
const url = new URL(`http://${address}`);
|
|
12
|
+
const prettified = url.hostname;
|
|
13
|
+
if (isIpv6 && !encloseIpv6) {
|
|
14
|
+
return prettified.substring(1, prettified.length - 1);
|
|
15
|
+
}
|
|
16
|
+
return prettified;
|
|
17
|
+
}
|
|
18
|
+
exports.prettify = prettify;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PrettifyOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to enclose IPv6 addresses into square brackets
|
|
4
|
+
* (according to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2))
|
|
5
|
+
*
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
encloseIpv6?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function prettify(address: string, options?: PrettifyOptions): string;
|
package/ip/prettify.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PrettifyOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to enclose IPv6 addresses into square brackets
|
|
4
|
+
* (according to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2))
|
|
5
|
+
*
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
encloseIpv6?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function prettify(address: string, options?: PrettifyOptions): string;
|
package/ip/prettify.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function prettify(address, options) {
|
|
2
|
+
const {
|
|
3
|
+
encloseIpv6 = false
|
|
4
|
+
} = options || {};
|
|
5
|
+
const isIpv6 = address.includes(":");
|
|
6
|
+
if (isIpv6) {
|
|
7
|
+
address = `[${address}]`;
|
|
8
|
+
}
|
|
9
|
+
const url = new URL(`http://${address}`);
|
|
10
|
+
const prettified = url.hostname;
|
|
11
|
+
if (isIpv6 && !encloseIpv6) {
|
|
12
|
+
return prettified.substring(1, prettified.length - 1);
|
|
13
|
+
}
|
|
14
|
+
return prettified;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
prettify
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/net",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"description": "experimental network abstractions",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@fuman/io": "^0.0.
|
|
10
|
-
"@fuman/utils": "^0.0.
|
|
9
|
+
"@fuman/io": "^0.0.15",
|
|
10
|
+
"@fuman/utils": "^0.0.15"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
package/proxy/http/connect.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TcpEndpoint } from '../../types.js';
|
|
2
1
|
import { IReadable, IWritable } from '@fuman/io';
|
|
2
|
+
import { TcpEndpoint } from '../../types.js';
|
|
3
3
|
import { HttpProxySettings } from './types.js';
|
|
4
4
|
export declare function performHttpProxyHandshake(reader: IReadable, writer: IWritable, proxy: HttpProxySettings, destination: TcpEndpoint): Promise<void>;
|
package/proxy/http/connect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TcpEndpoint } from '../../types.js';
|
|
2
1
|
import { IReadable, IWritable } from '@fuman/io';
|
|
2
|
+
import { TcpEndpoint } from '../../types.js';
|
|
3
3
|
import { HttpProxySettings } from './types.js';
|
|
4
4
|
export declare function performHttpProxyHandshake(reader: IReadable, writer: IWritable, proxy: HttpProxySettings, destination: TcpEndpoint): Promise<void>;
|