]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - libratbox/src/nossl.c
Only count throttle entries that cause rejection in /stats t.
[irc/rqf/shadowircd.git] / libratbox / src / nossl.c
index c27a0c76a79b7f7855ba46141c43b50e90ef6f5b..125bed951a6c4a6b42cb476c170a9442294042a1 100644 (file)
 
 #include <libratbox_config.h>
 #include <ratbox_lib.h>
-
 #if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS)
 
+#include "arc4random.h"
+
 #include <commio-int.h>
 #include <commio-ssl.h>
 
-int 
+int
 rb_setup_ssl_server(const char *cert, const char *keyfile, const char *dhfile)
 {
        errno = ENOSYS;
@@ -54,17 +55,44 @@ rb_ssl_listen(rb_fde_t *F, int backlog)
        return -1;
 }
 
-int rb_init_prng(const char *path, prng_seed_t seed_type)
+static void
+rb_stir_arc4random(void *unused)
 {
-       return -1;
+       arc4random_stir();
+}
+
+
+int
+rb_init_prng(const char *path, prng_seed_t seed_type)
+{
+       /* xxx this ignores the parameters above */
+       arc4random_stir();
+       rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
+       return 1;
 }
 
 int
 rb_get_random(void *buf, size_t length)
 {
-       return -1;
+       uint32_t rnd = 0, i;
+       uint8_t *xbuf = buf;
+       for(i = 0; i < length; i++)
+       {
+               if(i % 4 == 0)
+                       rnd = arc4random();
+               xbuf[i] = rnd;
+               rnd >>= 8;
+       }
+       return 1;
+}
+
+int
+rb_get_pseudo_random(void *buf, size_t length)
+{
+       return rb_get_random(buf, length);
 }
 
+
 const char *
 rb_get_ssl_strerror(rb_fde_t *F)
 {
@@ -72,21 +100,21 @@ rb_get_ssl_strerror(rb_fde_t *F)
        return nosupport;
 }
 
-void 
-rb_ssl_start_accepted(rb_fde_t *new_F, ACCB *cb, void *data, int timeout)
+void
+rb_ssl_start_accepted(rb_fde_t *new_F, ACCB * cb, void *data, int timeout)
 {
        return;
 }
 
-void 
-rb_ssl_start_connected(rb_fde_t *F, CNCB *callback, void *data, int timeout)
+void
+rb_ssl_start_connected(rb_fde_t *F, CNCB * callback, void *data, int timeout)
 {
        return;
 }
 
 void
-rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest, 
-                     struct sockaddr *clocal, int socklen, CNCB *callback, void *data, int timeout)
+rb_connect_tcp_ssl(rb_fde_t *F, struct sockaddr *dest,
+                  struct sockaddr *clocal, int socklen, CNCB * callback, void *data, int timeout)
 {
        return;
 }
@@ -98,28 +126,41 @@ rb_supports_ssl(void)
 }
 
 void
-rb_ssl_shutdown(rb_fde_t * F)
-{  
+rb_ssl_shutdown(rb_fde_t *F)
+{
        return;
-}        
+}
 
 void
-rb_ssl_accept_setup(rb_fde_t * F, int new_fd, struct sockaddr *st, int addrlen)
+rb_ssl_accept_setup(rb_fde_t *F, rb_fde_t *new_F, struct sockaddr *st, int addrlen)
 {
        return;
 }
 
 ssize_t
-rb_ssl_read(rb_fde_t * F, void *buf, size_t count)
+rb_ssl_read(rb_fde_t *F, void *buf, size_t count)
 {
-       return 0;
+       errno = ENOSYS;
+       return -1;
 }
 
 ssize_t
-rb_ssl_write(rb_fde_t * F, const void *buf, size_t count)
+rb_ssl_write(rb_fde_t *F, const void *buf, size_t count)
+{
+       errno = ENOSYS;
+       return -1;
+}
+
+unsigned int
+rb_ssl_handshake_count(rb_fde_t *F)
 {
        return 0;
 }
 
-#endif /* !HAVE_OPENSSL */
+void
+rb_ssl_clear_handshake_count(rb_fde_t *F)
+{
+       return;
+}
 
+#endif /* !HAVE_OPENSSL */