コード例 #1
0
ファイル: util.c プロジェクト: hogand/http
void
log_request(struct url *url, struct url *proxy)
{
	int custom_port = 0;

	switch (url->proto) {
	case HTTP:
		custom_port = (strcmp(url->port, "80")) ? 1 : 0;
		break;
	case HTTPS:
		custom_port = (strcmp(url->port, "443")) ? 1 : 0;
		break;
	case FTP:
		custom_port = (strcmp(url->port, "21")) ? 1 : 0;
		break;
	}

	if (proxy)
		log_info("Requesting %s://%s%s%s%s%s%s%s"
		    " (via %s://%s%s%s%s%s%s)\n",
		    proto_str(url->proto),
		    (url->user[0]) ? url->user : "",
		    (url->pass[0]) ? ":*****" : "",
		    (url->user[0] || url->pass[0]) ? "@" : "",
		    url->host,
		    (custom_port) ? ":" : "",
		    (custom_port) ? url->port : "",
		    url->path,

		    /* via proxy part */
		    (proxy->proto == HTTP) ? "http" : "https",
		    (proxy->user[0]) ? proxy->user : "",
		    (proxy->pass[0]) ? ":*****" : "",
		    (proxy->user[0] || proxy->pass[0]) ? "@" : "",
		    proxy->host,
		    (proxy->port[0]) ? ":" : "",
		    (proxy->port[0]) ? proxy->port : "");
	else
		log_info("Requesting %s://%s%s%s%s%s%s%s\n",
		    proto_str(url->proto),
		    (url->user[0]) ? url->user : "",
		    (url->pass[0]) ? ":*****" : "",
		    (url->user[0] || url->pass[0]) ? "@" : "",
		    url->host,
		    (custom_port) ? ":" : "",
		    (custom_port) ? url->port : "",
		    url->path);
}
コード例 #2
0
ファイル: nfct-snatlog.c プロジェクト: deba12/nfct-snatlog
static int event_cb(enum nf_conntrack_msg_type type,
		    struct nf_conntrack *ct,
		    void *data) {
   struct conntrack_list *no;
   u_int8_t l4proto;

   // we are interested only in SNAT connections
   if (!nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT))
      return NFCT_CB_CONTINUE;

   // We are interested only in TCP/UDP L4 protocols...
   l4proto = nfct_get_attr_u8(ct,ATTR_ORIG_L4PROTO);
   if (l4proto != IPPROTO_TCP && l4proto != IPPROTO_UDP)
      return NFCT_CB_CONTINUE;

   if (verbose_flag) {
      print_verbose(ct, type, proto_str(l4proto));
   }

   switch(type) {
      case NFCT_T_NEW:
         no = (struct conntrack_list *)malloc(sizeof(struct conntrack_list));
         no->id = nfct_get_attr_u32(ct,ATTR_ID);
         no->orig_ipv4_src = nfct_get_attr_u32(ct,ATTR_ORIG_IPV4_SRC);
         no->orig_port_src = nfct_get_attr_u16(ct,ATTR_ORIG_PORT_SRC);
         time(&no->timestamp);
         list_add(&ct_list, no);
         break;
      case NFCT_T_DESTROY:
         no = list_find(ct_list,
               nfct_get_attr_u32(ct,ATTR_ID),
               nfct_get_attr_u32(ct,ATTR_ORIG_IPV4_SRC),
               nfct_get_attr_u16(ct,ATTR_ORIG_PORT_SRC));
         if (no) {
            print_snatlog(ct, &no->timestamp, proto_str(l4proto));
            list_del(&ct_list,no);
         }
         break;
      default:
         break;
   }

   return NFCT_CB_CONTINUE;
}
コード例 #3
0
ファイル: radlast.c プロジェクト: Distrotech/radius
int
rawread()
{
        int wfd;
        struct radutmp ut;
        struct tm *tm;
        char ct[256];
        grad_uint32_t ipaddr;
        char ip_str[GRAD_IPV4_STRING_LENGTH];
        
        if ((wfd = open(file, O_RDONLY, 0)) < 0) {
                grad_log(GRAD_LOG_ERR|GRAD_LOG_PERROR, 
                         _("can't open file %s"), file);
                exit(1);
        }
        while (read(wfd, &ut, sizeof ut) == sizeof ut) {
                tm = localtime(&ut.time);
                strftime(ct, sizeof(ct), "%c", tm);

                ipaddr = ut.framed_address;
                grad_ip_iptostr(ntohl(ipaddr), ip_str);
                
                printf("%d %-*.*s %-*.*s %3.3d %-4.4s %2s %-*.*s %-*.*s %-*.*s %10.10s %5.5s\n",
                       ut.type,
                       
                       namesize, namesize,
                       ut.login,
                       
                       nas_name_len, nas_name_len,
                       grad_nas_ip_to_name(ntohl(ut.nas_address)),

                       ut.nas_port,

                       proto_str(ut.proto),

                       port_type_str(ut.porttype),

                       RUT_IDSIZE, RUT_IDSIZE,
                       ut.session_id,

                       RUT_PNSIZE, RUT_PNSIZE,
                       ut.caller_id[0] == 0 ? "?" : ut.caller_id,
                       
                       IP_ADDR_LEN, IP_ADDR_LEN,
                       ip_str,
                       
                       ct, ct + 11);
        }
        close(wfd);
        return;
}
コード例 #4
0
ファイル: radlast.c プロジェクト: Distrotech/radius
/* NOTE:
 *  short format is:
 * LOGIN      NAS     PORT FRAMED-IP       START_TIME - STOP_TIME (DURATION)
 *  long format is:
 * LOGIN      NAS     PORT PROTO PORT_TYPE SESSION_ID  CALLER_ID FRAMED-IP       START_TIME - STOP_TIME (DURATION)
 */
void
print_entry(WTMP *pp, struct radutmp *bp, int mark)
{
        struct tm *tm;
        char ct[256];
        char ip_str[IP_ADDR_LEN+1];
        time_t delta;
        grad_uint32_t ipaddr;
        char buf[GRAD_MAX_LONGNAME];
        
        tm = localtime(&bp->time);
        strftime(ct, sizeof(ct), "%a %b %d %H:%M", tm);

        ipaddr = bp->framed_address;
        if (ipaddr == 0 && pp)
                ipaddr = pp->ut.framed_address;
        grad_ip_iptostr(ntohl(ipaddr), ip_str);

        if (long_fmt) {                                   
                printf("%-*.*s %-*.*s %3.3d %-4.4s %2s %-*.*s %-*.*s %-*.*s %16.16s ",
                       namesize, namesize,
                       bp->login,
                       
                       nas_name_len, nas_name_len,
                       grad_nas_ip_to_name(ntohl(bp->nas_address),
					   buf, sizeof buf),

                       bp->nas_port,

                       proto_str(bp->proto),

                       port_type_str(bp->porttype),

                       RUT_IDSIZE, RUT_IDSIZE,
                       bp->session_id,

                       RUT_PNSIZE, RUT_PNSIZE,
                       bp->caller_id[0] == 0 ? "?" : bp->caller_id,
                       
                       IP_ADDR_LEN, IP_ADDR_LEN,
                       ip_str,
                       
                       ct);
        } else {
                printf("%-*.*s %-*.*s %3.3d %-*.*s %16.16s ",
                       namesize, namesize,
                       bp->login,
                       
                       nas_name_len, nas_name_len,
                       grad_nas_ip_to_name(ntohl(bp->nas_address),
					   buf, sizeof buf),

                       bp->nas_port,

                       IP_ADDR_LEN, IP_ADDR_LEN,
                       ip_str,
                       
                       ct);
        }
        
        if (pp == NULL) {
                printf(_("still logged in"));
        } else {
                tm = localtime(&pp->ut.time);
                strftime(ct, sizeof(ct), "%H:%M", tm);
                printf("- %5.5s", ct);

                /*delta = pp->ut.duration;*/
                delta = pp->ut.time - bp->time;
                if (show_seconds) {
                        printf("  (%8lu)", delta);
                } else {
                        if (delta < 0)
                                delta = 0;
                        tm = gmtime(&delta);
                        strftime(ct, sizeof(ct), "%H:%M:%S", tm);
                        if (delta < 86400)
                                printf("  (%*.*s)", width, width, ct);
                        else
                                printf(" (%ld+%*.*s)",
                                       delta / 86400, width, width, ct);
                }
        }
        if (mark)
                printf(" !");
        printf("\n");
}