โมดูล nodejs สำหรับการทำงานกับอินเทอร์เฟซผู้ดูแลระบบ CJDNS ผ่าน UDP ออกแบบมาให้มีความสม่ำเสมอ ทนทาน และใช้งานง่าย
กระโดด:
สามารถใช้ได้ผ่านทาง npm
npm install cjdns-admin
ฟังก์ชัน createAdmin ส่งคืน EventEmitter4 พร้อมสมาชิกสำหรับแต่ละฟังก์ชันผู้ดูแลระบบและฟังก์ชันสำรอง นอกจากนี้ยังมีสมาชิกที่จัดการเพจอัตโนมัติสำหรับฟังก์ชันที่ถูกเพจ
ตัวเลือก:
การใช้งาน:
var cjdnsAdmin = require ( 'cjdns-admin' ) ,
admin ,
channel ;
// create a new Admin
admin = cjdnsAdmin . createAdmin ( {
ip : '127.0.0.1' ,
port : 11234 ,
password : 'my cjdns password'
} ) ;
// ping the admin
channel = admin . ping ( ) ;
// create a response handler
function pingResponse ( res ) {
// process ping response
console . dir ( res ) ;
}
// handle the response
admin . on ( channel , pingResponse ) ; | ต้นฉบับ | สลับกัน |
|---|---|
| ผู้ดูแลระบบ_asyncเปิดใช้งานแล้ว | admin.asyncEnabled |
| Admin_availableฟังก์ชั่น | admin.availableฟังก์ชั่น |
| admin.availableFunctionsPaged | |
| AdminLog_logมากมาย | log.logหลาย |
| AdminLog_subscribe | เข้าสู่ระบบสมัครสมาชิก |
| AdminLog_subscriptions | log.สมัครสมาชิก |
| AdminLog_unsubscribe | เข้าสู่ระบบยกเลิกการสมัคร |
| Allocator_bytesจัดสรรแล้ว | allocator.bytesจัดสรร |
| Allocator_snapshot | ตัวจัดสรรภาพรวม |
| รหัสผ่านที่ได้รับอนุญาต_เพิ่ม | รหัสผ่านที่ได้รับอนุญาต.เพิ่ม |
| รหัสผ่านที่ได้รับอนุญาต_list | รหัสผ่านที่ได้รับอนุญาต.รายการ |
| รหัสผ่านที่ได้รับอนุญาต_remove | รหัสผ่านที่ได้รับอนุญาต ลบออก |
| Core_exit | core.ออก |
| Core_initTunnel | core.initTunnel |
| Core_pid | core.pid |
| InterfaceController_disconnectPeer | interfaceController.disconnectPeer |
| InterfaceController_peerStats | interfaceController.peerStats |
| interfaceController.peerStatsPaged | |
| IpTunnel_allowConnection | ipTunnel.allowConnection |
| IpTunnel_connectTo | ipTunnel.connectTo |
| IpTunnel_listConnections | ipTunnel.listConnections |
| IpTunnel_removeConnection | ipTunnel.removeConnection |
| IpTunnel_showConnection | ipTunnel.showConnection |
| Janitor_dumpRumorMill | janitor.dumpRumorMill |
| หน่วยความจำ | ผู้ดูแลระบบ.หน่วยความจำ |
| nodeStore.dumpTablePaged | |
| NodeStore_getLink | nodeStore.getLink |
| NodeStore_getRouteLabel | nodeStore.getRouteLabel |
| NodeStore_nodeForAddr | nodeStore.nodeForAddr |
| ปิง | ผู้ดูแลระบบ.ปิง |
| เราเตอร์Module_findNode | เราเตอร์Module.findNode |
| RouterModule_getPeers | routerModule.getPeers |
| เราเตอร์Module_lookup | เราเตอร์โมดูลการค้นหา |
| RouterModule_nextHop | เราเตอร์Module.nextHop |
| เราเตอร์Module_pingNode | เราเตอร์Module.pingNode |
| SearchRunner_showActiveSearch | searchRunner.showActiveSearch |
| SearchRunner_search | searchRunner.ค้นหา |
| Security_checkสิทธิ์ | security.checkสิทธิ์ |
| Security_chroot | security.chroot |
| Security_getUser | security.getUser |
| ความปลอดภัย_nofiles | ความปลอดภัย nofiles |
| การรักษาความปลอดภัย_noforks | การรักษาความปลอดภัย noforks |
| Security_seccomp | security.seccomp |
| Security_setup เสร็จสมบูรณ์ | การรักษาความปลอดภัยการตั้งค่าเสร็จสมบูรณ์ |
| Security_setUser | security.setUser |
| SessionManager_getHandles | sessionManager.getHandles |
| sessionManager.getHandlesPaged | |
| SessionManager_sessionStats | sessionManager.sessionStats |
| สวิตช์Pinger_ping | switchPinger.ping |
| UDPInterface_beginการเชื่อมต่อ | udpInterface.beginConnection |
| UDPInterface_new | udpInterface.ใหม่ |
การใช้งาน:
channel = admin . asyncEnabled ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . availableFunctions ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
count : 0
} ;
channel = admin . log . logMany ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
file : '' ,
level : '' ,
line : 0
} ;
channel = admin . log . subscribe ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . log . subscriptions ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
streamId : ''
} ;
channel = admin . log . unsubscribe ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . allocator . bytesAllocated ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
includeAllocations : 0
} ;
channel = admin . allocator . snapshot ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
authType : 0 ,
ipv6 : '' ,
password : '' ,
user : ''
} ;
channel = admin . authorizedPasswords . add ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . authorizedPasswords . list ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
user : ''
} ;
channel = admin . authorizedPasswords . remove ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . core . exit ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
desiredTunName : ''
} ;
channel = admin . core . initTunnel ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . core . pid ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
pubkey : ''
} ;
channel = admin . interfaceController . disconnectPeer ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . interfaceController . peerStats ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
ip4Address : '' ,
ip4Prefix : 0 ,
ip6Address : '' ,
ip6Prefix : 0 ,
publicKeyOfAuthorizedNode : ''
} ;
channel = admin . ipTunnel . allowConnection ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
publicKeyOfNodeToConnectTo : ''
} ;
channel = admin . ipTunnel . connectTo ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . ipTunnel . listConnections ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
connection : 0
} ;
channel = admin . ipTunnel . removeConnection ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
connection : 0
} ;
channel = admin . ipTunnel . showConnection ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
mill : '' ,
page : 0
} ;
channel = admin . janitor . dumpRumorMill ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . memory ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . nodeStore . dumpTable ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
linkNum : 0 ,
parent : ''
} ;
channel = admin . nodeStore . getLink ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
pathParentToChild : '' ,
pathToParent : ''
} ;
channel = admin . nodeStore . getRouteLabel ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
ip : ''
} ;
channel = admin . nodeStore . nodeForAddr ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . ping ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
nodeToQuery : '' ,
target : '' ,
timeout : 0
} ;
channel = admin . routerModule . findNode ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
nearbyPath : '' ,
path : '' ,
timeout : 0
} ;
channel = admin . routerModule . getPeers ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
address : ''
} ;
channel = admin . routerModule . lookup ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
nodeToQuery : '' ,
target : '' ,
timeout : 0
} ;
channel = admin . routerModule . nextHop ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
path : '' ,
timeout : 0
} ;
channel = admin . routerModule . pingNode ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
ipv6 : '' ,
maxRequests : 0
} ;
channel = admin . searchRunner . search ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
number : 0
} ;
channel = admin . searchRunner . showActiveSearch ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . security . checkPermissions ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
root : ''
} ;
channel = admin . security . chroot ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
user : ''
} ;
channel = admin . security . getUser ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . security . nofiles ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . security . noforks ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . security . seccomp ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
channel = admin . security . setupComplete ( ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
keepNetAdmin : 0 ,
uid : 0
} ;
channel = admin . security . setUser ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . sessionManager . getHandles ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
handle : 0
} ;
channel = admin . sessionManager . sessionStats ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
data : '' ,
keyPing : 0 ,
path : '' ,
timeout : 0
} ;
channel = admin . switchPinger . ping ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
address : '' ,
interfaceNumber : 0 ,
password : '' ,
publicKey : ''
} ;
channel = admin . udpInterface . beginConnection ( options ) ;
admin . once ( channel , processResponse ) ;การใช้งาน:
var channel ,
options ;
options = {
bindAddress : ''
} ;
channel = admin . udpInterface . new ( options ) ;
admin . once ( channel , processResponse ) ; ฟังก์ชั่นเพจจะดึงเพจทั้งหมดและส่งคืนผลลัพธ์ ตัวเลือกการส่งผ่านเป็นทางเลือก การโทรกลับได้รับ err และ results เป็นอาร์กิวเมนต์ และทั้งสองประเภทเป็นประเภท Array
function pagedCallback ( err , results ) {
if ( err ) {
return console . log ( 'paged callback error' , err ) ;
}
console . log ( 'paged function results array' , ) ;
}
admin . availableFunctionsPaged ( pagedCallback ) ;
admin . interfaceController . peerStatsPaged ( pagedCallback ) ;
admin . nodeStore . dumpTablePaged ( pagedCallback ) ;
admin . sessionManager . getHandlesPaged ( pagedCallback ) ;
// mill property is optional
admin . janitor . dumpRumorMillPaged ( { mill : '' } , pagedCallback ) ; สร้างตัวแปรสภาพแวดล้อมที่การทดสอบจะมองหา:
# cjdns development environment
export CJDNS_ADMIN_PORT=11234
export CJDNS_ADMIN_IP=127.0.0.1
export CJDNS_ADMIN_PASSWORD=from your cjdroute config
เครื่องมือพร้อมใช้งานผ่านสคริปต์ npm ดู package.json ในส่วน scripts
npm run lint
# test offline functionality
npm test
npm test -- --watch
# test online, UDP, and potentially dangerous functions
# on an actual node
npm run test-live
npm run test-live -- --watch
# render docs to html for testing
npm run doc-gen
npm run doc-watch