Modul nodejs untuk bekerja dengan antarmuka admin CJDNS melalui UDP. Itu dibuat agar konsisten, kuat dan mudah digunakan.
Melompat:
Ini tersedia melalui npm
npm install cjdns-admin
Fungsi createAdmin
mengembalikan EventEmitter4 dengan anggota untuk setiap fungsi admin dan penggantinya. Ini juga berisi anggota yang menangani paging otomatis untuk fungsi-fungsi yang diberi halaman.
Pilihan:
Penggunaan:
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 ) ;
Asli | Bergantian |
---|---|
Admin_asyncDiaktifkan | admin.asyncEnabled |
Admin_tersediaFungsi | admin.availableFunctions |
admin.availableFunctionsPaged | |
AdminLog_logBanyak | log.logBanyak |
AdminLog_berlangganan | log.berlangganan |
AdminLog_langganan | log.langganan |
AdminLog_berhenti berlangganan | log.berhenti berlangganan |
Pengalokasi_byte Dialokasikan | pengalokasi.bytesDialokasikan |
Pengalokasi_snapshot | pengalokasi.snapshot |
Kata Sandi Resmi_tambahkan | kata sandi resmi.tambahkan |
Daftar_Kata Sandi Resmi | kata sandi resmi.daftar |
Kata Sandi Resmi_hapus | kata sandi resmi.hapus |
Inti_keluar | inti.keluar |
Core_initTunnel | core.initTunnel |
Inti_pid | inti.pid |
InterfaceController_disconnectPeer | antarmukaController.disconnectPeer |
InterfaceController_peerStats | antarmukaController.peerStats |
interfaceController.peerStatsPaged | |
IpTunnel_allowConnection | ipTunnel.allowConnection |
IpTunnel_connectTo | ipTunnel.connectTo |
IpTunnel_listConnections | ipTunnel.listConnections |
IpTunnel_removeConnection | ipTunnel.removeConnection |
IpTunnel_showConnection | ipTunnel.showConnection |
Petugas kebersihan_dumpRumorMill | petugas kebersihan.dumpRumorMill |
ingatan | admin.memori |
nodeStore.dumpTablePaged | |
NodeStore_getLink | nodeStore.getLink |
NodeStore_getRouteLabel | nodeStore.getRouteLabel |
NodeStore_nodeForAddr | nodeStore.nodeForAddr |
ping | admin.ping |
RouterModule_findNode | routerModule.findNode |
RouterModule_getPeers | routerModule.getPeers |
RouterModule_lookup | routerModule.lookup |
RouterModule_nextHop | routerModule.nextHop |
RouterModule_pingNode | routerModule.pingNode |
SearchRunner_showActiveSearch | searchRunner.showActiveSearch |
PencarianRunner_pencarian | pencarianRunner.pencarian |
Keamanan_periksaIzin | keamanan.checkPermissions |
Keamanan_chroot | keamanan.chroot |
Keamanan_dapatkanPengguna | keamanan.getUser |
Keamanan_nofiles | keamanan.nofiles |
Keamanan_noforks | keamanan.noforks |
Keamanan_seccomp | keamanan.seccomp |
Keamanan_setupSelesai | keamanan.setupLengkap |
Keamanan_setPengguna | keamanan.setUser |
SessionManager_getHandles | sessionManager.getHandles |
sessionManager.getHandlesPaged | |
SessionManager_sessionStats | sessionManager.sessionStats |
BeralihPinger_ping | beralihPinger.ping |
UDPInterface_beginConnection | udpInterface.beginConnection |
UDPInterface_new | udpInterface.baru |
Penggunaan:
channel = admin . asyncEnabled ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . availableFunctions ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
count : 0
} ;
channel = admin . log . logMany ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
file : '' ,
level : '' ,
line : 0
} ;
channel = admin . log . subscribe ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . log . subscriptions ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
streamId : ''
} ;
channel = admin . log . unsubscribe ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . allocator . bytesAllocated ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
includeAllocations : 0
} ;
channel = admin . allocator . snapshot ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
authType : 0 ,
ipv6 : '' ,
password : '' ,
user : ''
} ;
channel = admin . authorizedPasswords . add ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . authorizedPasswords . list ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
user : ''
} ;
channel = admin . authorizedPasswords . remove ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . core . exit ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
desiredTunName : ''
} ;
channel = admin . core . initTunnel ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . core . pid ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
pubkey : ''
} ;
channel = admin . interfaceController . disconnectPeer ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . interfaceController . peerStats ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
ip4Address : '' ,
ip4Prefix : 0 ,
ip6Address : '' ,
ip6Prefix : 0 ,
publicKeyOfAuthorizedNode : ''
} ;
channel = admin . ipTunnel . allowConnection ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
publicKeyOfNodeToConnectTo : ''
} ;
channel = admin . ipTunnel . connectTo ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . ipTunnel . listConnections ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
connection : 0
} ;
channel = admin . ipTunnel . removeConnection ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
connection : 0
} ;
channel = admin . ipTunnel . showConnection ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
mill : '' ,
page : 0
} ;
channel = admin . janitor . dumpRumorMill ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . memory ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . nodeStore . dumpTable ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
linkNum : 0 ,
parent : ''
} ;
channel = admin . nodeStore . getLink ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
pathParentToChild : '' ,
pathToParent : ''
} ;
channel = admin . nodeStore . getRouteLabel ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
ip : ''
} ;
channel = admin . nodeStore . nodeForAddr ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . ping ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
nodeToQuery : '' ,
target : '' ,
timeout : 0
} ;
channel = admin . routerModule . findNode ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
nearbyPath : '' ,
path : '' ,
timeout : 0
} ;
channel = admin . routerModule . getPeers ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
address : ''
} ;
channel = admin . routerModule . lookup ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
nodeToQuery : '' ,
target : '' ,
timeout : 0
} ;
channel = admin . routerModule . nextHop ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
path : '' ,
timeout : 0
} ;
channel = admin . routerModule . pingNode ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
ipv6 : '' ,
maxRequests : 0
} ;
channel = admin . searchRunner . search ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
number : 0
} ;
channel = admin . searchRunner . showActiveSearch ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . security . checkPermissions ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
root : ''
} ;
channel = admin . security . chroot ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
user : ''
} ;
channel = admin . security . getUser ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . security . nofiles ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . security . noforks ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . security . seccomp ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
channel = admin . security . setupComplete ( ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
keepNetAdmin : 0 ,
uid : 0
} ;
channel = admin . security . setUser ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
page : 0
} ;
channel = admin . sessionManager . getHandles ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
handle : 0
} ;
channel = admin . sessionManager . sessionStats ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
data : '' ,
keyPing : 0 ,
path : '' ,
timeout : 0
} ;
channel = admin . switchPinger . ping ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
address : '' ,
interfaceNumber : 0 ,
password : '' ,
publicKey : ''
} ;
channel = admin . udpInterface . beginConnection ( options ) ;
admin . once ( channel , processResponse ) ;
Penggunaan:
var channel ,
options ;
options = {
bindAddress : ''
} ;
channel = admin . udpInterface . new ( options ) ;
admin . once ( channel , processResponse ) ;
Fungsi paged akan mengambil semua halaman dan mengembalikan hasilnya. Opsi passing adalah opsional. Callback menerima err
dan results
sebagai argumen dan keduanya merupakan tipe 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 ) ;
Buat variabel lingkungan yang akan dicari oleh pengujian:
# cjdns development environment
export CJDNS_ADMIN_PORT=11234
export CJDNS_ADMIN_IP=127.0.0.1
export CJDNS_ADMIN_PASSWORD=from your cjdroute config
Alat tersedia melalui skrip npm. Lihat package.json
di bagian 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