📄 ipc.xpl
字号:
<?xml version="1.0"?><!DOCTYPE methoddef SYSTEM "rpc-method.dtd"><methoddef><name>IPC</name><version>1.0</version><signature>string string struct</signature><help>Description: Allows the forked server to access core data and subsArguments: A list containing $comm the command (sub) to execute on the Core side, or the name of a core variable $args a ref to a struct containing the key-value pairs for the sub, or the index for core vars AuthToken token to authenticate method callerReturns: it depends on the sub - the same as it does</help><code language="perl"><![CDATA[#!/usr/bin/perl################################################################################# Sub Name: IPC# Description: Allows the forked server to access core data and subs## Arguments: a list containing# $comm string the command (sub) to execute on the Core side,# or the name of a core variable# $args struct ref contains the key-value pairs for the sub,# or the index for core vars, and the# AuthToken key-token for authenticate method caller## Returns: it depends on the sub - the same as it does################################################################################sub IPC { my $self = shift; my $comm = shift; my $args = shift; my $hisToken = $$args{AuthToken}; my $i; # Authentication method caller if ( $hisToken ne $RRDMlib::IPC_token ) { # caller unauthorized node_log ("IPC request (command: $comm) unauthorized", 1, 'r'); return undef; } # Caller authorized. Go on #print "IPC on Status Server: $comm\n"; #foreach (keys %$args) { # print "IPC args: $_, $$args{$_}\n"; #} if ($comm eq 'Find_Nod') { my ( $n_LH_r, $n_TR_r, $FP_LH_r, $FP_TR_r, $por_LH_r, $por_TR_r) = &RRDMlib::Find_Nod ( $$args{client}, $$args{transport}, $$args{program}, $$args{min_msk}); #print "@$n_LH_r, @$n_TR_r, @$FP_LH_r, @$FP_TR_r, @$por_LH_r, @$por_TR_r\n"; return {n_LH => [ @$n_LH_r ], n_TR => [ @$n_TR_r ], FP_LH => [ @$FP_LH_r ], FP_TR => [ @$FP_TR_r ], por_LH => [ @$por_LH_r ], por_TR => [ @$por_TR_r ]}; } elsif ($comm eq 'Find_Roots') { my ( $roots_IP_r, $roots_port_r ) = &RRDMlib::Find_Roots ( $$args{program} ); return { roots_IP => $roots_IP_r, roots_port => $roots_port_r }; } elsif ($comm eq 'Prog_Peers_Del') { &RRDMlib::Prog_Peers_Del ( $$args{program} ); return ; } elsif ($comm eq 'Prog_Surro_Del') { &RRDMlib::Prog_Surro_Del ( $$args{program} ); return ; } elsif ($comm eq 'suri_del') { &RRDMlib::suri_del ( $$args{program}, $$args{node_r}, $$args{FP_r}); return ; } elsif ($comm eq 'show_table') { &RRDMlib::show_table ($$args{table}); return undef; } elsif ($comm eq 'save_suri') { &RRDMlib::save_suri ($$args{snode}, $$args{progr}, $$args{suri_r}, $$args{FPbn_TRr}, $$args{FPbn_LHr}); return undef; } elsif ($comm eq 'nodes' || $comm eq 'footp' || $comm eq 'surro' || $comm eq 'peers' || $comm eq 'origins') { my $data = 'RRDMlib::' . "$comm" . $$args{ind}; #print "IPC: synthesizing $data data on Status Server\n"; my $aa = eval "\$$data"; # directly access the data #print "IPC: returned $aa\n"; return { data => $aa }; } return '';}__END__]]></code></methoddef>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -