Exemple #1
0
static void
insert(struct map *m, const char *key, const char *value)
{
	struct map_op op;
	op.op = MAP_INSERT;
	op.key.p = atomString(key);
	op.value = atomString(value);
	mapSearch(m,&op);
}
Exemple #2
0
static int
tunnelDnsHandler(int status, GethostbynameRequestPtr request)
{
    TunnelPtr tunnel = request->data;

    if(status <= 0) {
        tunnelError(tunnel, 504,
                    internAtomError(-status, 
                                    "Host %s lookup failed",
                                    atomString(tunnel->hostname)));
        return 1;
    }

    if(request->addr->string[0] == DNS_CNAME) {
        if(request->count > 10)
            tunnelError(tunnel, 504, internAtom("CNAME loop"));
        do_gethostbyname(request->addr->string + 1, request->count + 1,
                         tunnelDnsHandler, tunnel);
        return 1;
    }

    do_connect(retainAtom(request->addr), 0,
               parentHost ? parentPort : tunnel->port,
               tunnelConnectionHandler, tunnel);
    return 1;
}
Exemple #3
0
/* PSIPHON: entire function */
static int
tunnelSplitTunnelingDnsHandler(int status, GethostbynameRequestPtr request)
{
    TunnelPtr tunnel = request->data;

    if(status <= 0) {
        tunnelError(tunnel, 504,
                    internAtomError(-status,
                                    "Host %s lookup failed",
                                    atomString(tunnel->hostname)));
        return 1;
    }

    if(request->addr->string[0] == DNS_CNAME) {
        if(request->count > 10)
            tunnelError(tunnel, 504, internAtom("CNAME loop"));
        do_gethostbyname_socks(request->addr->string + 1, request->count + 1,
                         tunnelSplitTunnelingDnsHandler, tunnel);
        return 1;
    }

    //Get IP from the request, check against our local networks list
    int local_addr = 0;
    if(request->addr->string[0] == DNS_A)
    {
        HostAddressPtr host_addr;
        host_addr = (HostAddressPtr) &request->addr->string[1];
        //we deal only with IPv4 addresses
        if(host_addr->af == 4)
        {
            struct in_addr servaddr;
            memcpy(&servaddr.s_addr, &host_addr->data, sizeof(struct in_addr));
            local_addr =  isLocalAddress(servaddr);
        }
    }

    if (local_addr != 0)
    {
        printf("PSIPHON-UNPROXIED:>>%s<<", request->name->string);
        fflush(NULL);
    }

    //Use SOCKS for IPs that are not local and connect directly to the ones that are
    //At this point the DNS record for the request should be cached, default TTL for DNS requests
    //is 240 seconds
    if(local_addr == 0)
    {
            do_socks_connect(parentHost ?
                    parentHost->string : tunnel->hostname->string,
                    parentHost ? parentPort : tunnel->port,
                    tunnelSocksHandler, tunnel);
    }
    else
    {
        do_connect(retainAtom(request->addr), 0,
                parentHost ? parentPort : tunnel->port,
                tunnelConnectionHandler, tunnel);
    }
    return 1;
}
Exemple #4
0
void atomAload(const char *strs[])
{
    char **searchPtr = (char **)strs;
    while(*searchPtr != NULL)
    {
        atomString(*searchPtr);
        searchPtr += 1;
    }
}
Exemple #5
0
static void
list(const char *root)
{
	atom a = atomString(root);
	int n = vfsList(a, NULL, 0);
	atom name[n];
	vfsList(a, name, n);
	int i;
	for (i=0;i<n;i++) {
		logPrintf("%s",atomToString(name[i]));
	}
}
Exemple #6
0
void atomVload(const char *str , ...)
{
   const char *searchPtr = str;
   va_list vlist;

   va_start(vlist , str);

   while(searchPtr != NULL)
   {
       atomString(searchPtr);
       searchPtr = va_arg(vlist , char *);
   }

   va_end(vlist);
}