… | |
… | |
197 | // only do action once every x seconds per host whole allowing bursts. |
197 | // only do action once every x seconds per host whole allowing bursts. |
198 | // this implementation ("splay list" ;) is inefficient, |
198 | // this implementation ("splay list" ;) is inefficient, |
199 | // but low on resources. |
199 | // but low on resources. |
200 | struct net_rate_limiter : list<net_rateinfo> |
200 | struct net_rate_limiter : list<net_rateinfo> |
201 | { |
201 | { |
202 | static const double ALPHA = 1. - 1. / 180.; // allow bursts |
202 | static const double ALPHA = 1. - 1. / 600.; // allow bursts |
203 | static const double CUTOFF = 10.; // one event every CUTOFF seconds |
203 | static const double CUTOFF = 10.; // one event every CUTOFF seconds |
204 | static const double EXPIRE = CUTOFF * 30.; // expire entries after this time |
204 | static const double EXPIRE = CUTOFF * 30.; // expire entries after this time |
205 | static const double MAXDIF = CUTOFF * (1. / (1. - ALPHA)); // maximum diff /count value |
205 | static const double MAXDIF = CUTOFF * (1. / (1. - ALPHA)); // maximum diff /count value |
206 | |
206 | |
207 | bool can (const sockinfo &si) { return can((u32)si.host); } |
207 | bool can (const sockinfo &si) { return can((u32)si.host); } |
208 | bool can (u32 host); |
208 | bool can (u32 host); |
209 | }; |
209 | }; |
210 | |
210 | |
211 | net_rate_limiter auth_rate_limiter, reset_rate_limiter; |
211 | net_rate_limiter auth_rate_limiter, reset_rate_limiter; |
212 | |
212 | |
… | |
… | |
910 | rsachallenge k; |
910 | rsachallenge k; |
911 | |
911 | |
912 | if (0 > RSA_private_decrypt (sizeof (p->encr), |
912 | if (0 > RSA_private_decrypt (sizeof (p->encr), |
913 | (unsigned char *)&p->encr, (unsigned char *)&k, |
913 | (unsigned char *)&p->encr, (unsigned char *)&k, |
914 | ::conf.rsa_key, RSA_PKCS1_OAEP_PADDING)) |
914 | ::conf.rsa_key, RSA_PKCS1_OAEP_PADDING)) |
915 | slog (L_ERR, _("%s(%s): challenge illegal or corrupted"), |
915 | slog (L_ERR, _("%s(%s): challenge illegal or corrupted (%s). mismatched key or config file?"), |
916 | conf->nodename, (const char *)rsi); |
916 | conf->nodename, (const char *)rsi, ERR_error_string (ERR_get_error (), 0)); |
917 | else |
917 | else |
918 | { |
918 | { |
919 | delete octx; |
919 | delete octx; |
920 | |
920 | |
921 | octx = new crypto_ctx (k, 1); |
921 | octx = new crypto_ctx (k, 1); |
… | |
… | |
954 | |
954 | |
955 | rsachallenge chg; |
955 | rsachallenge chg; |
956 | |
956 | |
957 | if (!rsa_cache.find (p->id, chg)) |
957 | if (!rsa_cache.find (p->id, chg)) |
958 | { |
958 | { |
959 | slog (L_ERR, _("%s(%s): unrequested auth response"), |
959 | slog (L_ERR, _("%s(%s): unrequested auth response ignored"), |
960 | conf->nodename, (const char *)rsi); |
960 | conf->nodename, (const char *)rsi); |
961 | break; |
961 | break; |
962 | } |
962 | } |
963 | else |
963 | else |
964 | { |
964 | { |
965 | crypto_ctx *cctx = new crypto_ctx (chg, 0); |
965 | crypto_ctx *cctx = new crypto_ctx (chg, 0); |
966 | |
966 | |
967 | if (!p->hmac_chk (cctx)) |
967 | if (!p->hmac_chk (cctx)) |
|
|
968 | { |
968 | slog (L_ERR, _("%s(%s): hmac authentication error on auth response, received invalid packet\n" |
969 | slog (L_ERR, _("%s(%s): hmac authentication error on auth response, received invalid packet\n" |
969 | "could be an attack, or just corruption or an synchronization error"), |
970 | "could be an attack, or just corruption or an synchronization error"), |
970 | conf->nodename, (const char *)rsi); |
971 | conf->nodename, (const char *)rsi); |
|
|
972 | break; |
|
|
973 | } |
971 | else |
974 | else |
972 | { |
975 | { |
973 | rsaresponse h; |
976 | rsaresponse h; |
974 | |
977 | |
975 | rsa_hash (p->id, chg, h); |
978 | rsa_hash (p->id, chg, h); |