Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C{
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <pthread.h>
- static pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER;
- void generate_uuid(char* buf) {
- pthread_mutex_lock(&lrand_mutex);
- long a = lrand48();
- long b = lrand48();
- long c = lrand48();
- long d = lrand48();
- pthread_mutex_unlock(&lrand_mutex);
- // SID must match this regex for Kount compat /^w{1,32}$/
- sprintf(buf, "frontend=%08lx%04lx%04lx%04lx%04lx%08lx",
- a,
- b & 0xffff,
- (b & ((long)0x0fff0000) >> 16) | 0x4000,
- (c & 0x0fff) | 0x8000,
- (c & (long)0xffff0000) >> 16,
- d
- );
- return;
- }
- }C
- import std;
- backend default {
- .host = "127.0.0.1";
- .port = "8080";
- .first_byte_timeout = 300s;
- .between_bytes_timeout = 300s;
- }
- backend admin {
- .host = "127.0.0.1";
- .port = "8080";
- .first_byte_timeout = 21600s;
- .between_bytes_timeout = 21600s;
- }
- acl crawler_acl {
- "127.0.0.1";
- }
- acl debug_acl {
- }
- sub generate_session {
- if (req.url ~ ".*[&?]SID=([^&]+).*") {
- set req.http.X-Varnish-Faked-Session = regsub(
- req.url, ".*[&?]SID=([^&]+).*", "frontend=1");
- } else {
- C{
- char uuid_buf [50];
- generate_uuid(uuid_buf);
- VRT_SetHdr(sp, HDR_REQ,
- "