⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findroot.xpl

📁 OpenCDN内容分发系统
💻 XPL
字号:
<?xml version="1.0"?><!DOCTYPE methoddef SYSTEM "rpc-method.dtd"><methoddef><name>FindRoot</name><version>1.1</version><signature>string struct</signature><help>Description:  Lets the Origin to poll FirstHop Transit candidates by UDP probing,  in order to find the best root for distribution. It is invocated  by RRDM as a FirstHop has to be found, and the result is communicated  back to itAccepts a struct containing:   KEY               VALUE   FH_n_r            array    FirstHop candidates   FH_FP_r           array    their footprints   FH_po_r           array    their ports   AuthToken         int      token to authenticate method callerReturns a struct containing:   KEY               VALUE   ret_code          int       numeric return code   ret_val           string    message string   index             string    Locates the best within the list</help><code language="perl"><![CDATA[#!/usr/bin/perl################################################################################   Sub Name:         FindRoot##   Description:      Lets the Origin to poll FirstHop Transit candidates#                     by UDP probing, in order to find the best root for#                     distribution. It is invocated by RRDM is a FirstHop#                     has to be found, and the result is communicated#                     back to it## Accepts a struct containing:#   KEY               VALUE#   FH_n_r            array    FirstHop candidates#   FH_FP_r           array    their footprints#   FH_po_r           array    their ports#   AuthToken         int      token to authenticate method caller## Returns a struct containing:#   KEY               VALUE#   ret_code          int      numeric return code#   ret_val           string   message string#   index             string   Locates the best within the list###############################################################################sub FindRoot {  use CommLib qw(node_log DBF_access find_best);  require "$Origin::opt_c";  OriginConfig->import(qw($origin_address));  my $arg_r    = pop @_;  my $FH_n_r   = $$arg_r{FH_n_r};  my $FH_FP_r  = $$arg_r{FH_FP_r};  my $FH_po_r  = $$arg_r{FH_po_r};  my $hisToken = $$arg_r{AuthToken};  my ($ret_code, $ret_val) = ('200', 'Origin did probed FirstHop candidates');  my ($auth_token, $hr, $index) = (undef, undef, '');  node_log ("FindRoot entered: FH_n, FH_FP, FH_po: @$FH_n_r, @$FH_FP_r, @$FH_po_r",             1, 'o');  $hr = DBF_access ("$Origin::origin_db", ['AuthToken'], 'r', 'o');  if ( %$hr ) {    $auth_token = $$hr{'AuthToken'};  } else {    $ret_code = '408';    $ret_val  = 'Unable to retrieve AuthToken from DB_File';    node_log ("FindRoot: $ret_code $ret_val", 1, 'o');  }  unless ( $ret_code ) {                   # sucessfull retrieval    if ( $hisToken ne $auth_token ) {      # RRDM impostor unauthorized      node_log ("$origin_address: FindRoot request unauthorized", 1, 'o');      $ret_code  = '401';      $ret_val   = 'Unauthorized';    } else {                               # Caller authorized. Go on      $index = find_best ($FH_n_r, $FH_po_r, $FH_FP_r, '',                           $origin_address, '0', 'o');    }  }  return { ret_code  => $ret_code,           ret_val   => $ret_val,           index     => $index };}__END__]]></code></methoddef>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -