k.net
HTTP, WebSocket, DNS, IP, and remote connections
| Execution Context | Prerequisites | Typical Use |
|---|---|---|
| KScript API, Page / View server scripts | Runtime network access to target endpoints or remote hosts | Outbound HTTP proxying, WebSocket upgrades, DNS/IP lookups, and remote ops |
k.net provides outbound network requests, real-time duplex communication, DNS and IP resolution, and remote terminal or file protocol clients in site scripts.
Quick Start
js
k.api.get("probe", () => {
const res = k.net.httpClient.send("https://httpbin.org/get", "get")
const ping = k.net.ping("kooboo.com")
return {
clientIp: k.net.IP.myIP,
httpStatus: res.statusCode,
pingReachable: ping.success
}
})Quick Reference
| Submodule / Member | Description | Details |
|---|---|---|
k.net.httpClient | Recommended: proxy forwarding, JSON/form/multipart, unified send, and batch tasks | httpClient |
k.net.url | Concise synchronous HTTP; quick text, JSON, or binary fetches (such as images) | url |
k.net.webSocket | Upgrade current requests to WebSocket and manage intrasite connections | webSocket |
k.net.DNS | Resolve A/MX/NS, reverse DNS, and Whois (case-sensitive) | DNS |
k.net.IP | Current client IP and IP geolocation lookups (case-sensitive) | IP |
k.net.ping(host) | Probe ICMP connectivity and round-trip latency | ping |
k.net.sshClient | Execute remote shell commands over SSH | sshClient |
k.net.sftpClient | Upload and download files over SFTP | sftpClient |
k.net.telnetClient | Read and write Telnet text-protocol sessions | telnetClient |
Choosing Between httpClient and url
| Scenario | Recommendation |
|---|---|
| API proxying, custom headers/bodies, or multipart uploads | k.net.httpClient |
Batch downloads or saving via KHttpResponse.save | k.net.httpClient (including batch) |
| Quickly fetching remote image or file bytes | k.net.url.getAsBinary(url) |
| One-line GET as string or JSON | k.net.url.get / k.net.url.getJson |
TypeScript Definitions
ts
interface KNET {
IP: KIP;
url: Curl;
httpClient: KHttpClient;
webSocket: KWebSocket;
DNS: KDNS;
sshClient: SshClient;
sftpClient: SftpClient;
telnetClient: TelnetClient;
ping(command: string): PingResult;
}
interface PingResult {
ip: string;
time: number;
success: boolean;
}