Navigation


Changeset 1396:188c82b6690b in freeDiameter for libfdcore/fdd.y


Ignore:
Timestamp:
Nov 15, 2019, 7:38:30 PM (4 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

Add ProcessingPeersPattern? and ProcessingPeersMinimum? parameters.

If this is configured, the process will accept all connections from
peers matching ProcessingPeersPattern?, but will NOT accept connections
from other peers until ProcessingPeersMinimum? peers of the first
type are connected.

This allows relays to only go online if there are enough worker
peers connected behind them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/fdd.y

    r1326 r1396  
    110110%token          LISTENON
    111111%token          THRPERSRV
     112%token          PROCESSINGPEERSPATTERN
     113%token          PROCESSINGPEERSMINIMUM
    112114%token          TCTIMER
    113115%token          TWTIMER
     
    142144                        | conffile listenon
    143145                        | conffile thrpersrv
     146                        | conffile processingpeerspattern
     147                        | conffile processingpeersminimum
    144148                        | conffile norelay
    145149                        | conffile appservthreads
     
    250254                                        { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } );
    251255                                conf->cnf_thr_srv = $3;
     256                        }
     257                        ;
     258
     259processingpeerspattern:         PROCESSINGPEERSPATTERN '=' QSTRING ';'
     260                        {
     261                                char *pattern = $3;
     262                                int err;
     263                                CHECK_FCT_DO( err=regcomp(&conf->cnf_processing_peers_pattern_regex, pattern, REG_EXTENDED | REG_NOSUB),
     264                                        {
     265                                                char * buf;
     266                                                size_t bl;
     267
     268                                                /* Error while compiling the regex */
     269                                                TRACE_DEBUG(INFO, "error while compiling the regular expression '%s':", pattern);
     270
     271                                                /* Get the error message size */
     272                                                bl = regerror(err, &conf->cnf_processing_peers_pattern_regex, NULL, 0);
     273
     274                                                /* Alloc the buffer for error message */
     275                                                CHECK_MALLOC( buf = malloc(bl) );
     276
     277                                                /* Get the error message content */
     278                                                regerror(err, &conf->cnf_processing_peers_pattern_regex, buf, bl);
     279                                                TRACE_DEBUG(INFO, "\t%s", buf);
     280
     281                                                /* Free the buffer, return the error */
     282                                                free(buf);
     283
     284                                                yyerror (&yylloc, conf, "Invalid regular expression in ProcessingPeersPattern");
     285                                                YYERROR;
     286                                        } );
     287                        }
     288                        ;
     289
     290processingpeersminimum:         PROCESSINGPEERSMINIMUM '=' INTEGER ';'
     291                        {
     292                                CHECK_PARAMS_DO( ($3 >= 0),
     293                                        { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } );
     294                                conf->cnf_processing_peers_minimum = $3;
    252295                        }
    253296                        ;
Note: See TracChangeset for help on using the changeset viewer.