forked from Mirrors/sngrep
Remove feature: address lookup resolution
This commit is contained in:
parent
7724712ae5
commit
79a54ce2a5
|
@ -976,50 +976,6 @@ dump_close(pcap_dumper_t *pd)
|
|||
pcap_dump_close(pd);
|
||||
}
|
||||
|
||||
const char *
|
||||
lookup_hostname(const char *address)
|
||||
{
|
||||
int i;
|
||||
int hostlen;
|
||||
in_addr_t netaddress;
|
||||
struct hostent *host;
|
||||
const char *hostname;
|
||||
|
||||
// No lookup enabled, return address as is
|
||||
if (!setting_enabled(SETTING_CAPTURE_LOOKUP))
|
||||
return address;
|
||||
|
||||
// Check if we have already tryied resolve this address
|
||||
for (i = 0; i < capture_cfg.dnscache.count; i++) {
|
||||
if (!strcmp(capture_cfg.dnscache.addr[i], address)) {
|
||||
return capture_cfg.dnscache.hostname[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the address to network byte order
|
||||
if ((netaddress = inet_addr(address)) == -1)
|
||||
return address;
|
||||
|
||||
// Lookup this addres
|
||||
host = gethostbyaddr(&netaddress, sizeof(netaddress), AF_INET);
|
||||
if (!host) {
|
||||
hostname = address;
|
||||
} else {
|
||||
hostname = host->h_name;
|
||||
}
|
||||
|
||||
// Max hostname length set to 16 chars
|
||||
hostlen = strlen(hostname);
|
||||
|
||||
// Store this result in the dnscache
|
||||
strcpy(capture_cfg.dnscache.addr[capture_cfg.dnscache.count], address);
|
||||
strncpy(capture_cfg.dnscache.hostname[capture_cfg.dnscache.count], hostname, hostlen);
|
||||
capture_cfg.dnscache.count++;
|
||||
|
||||
// Return the stored value
|
||||
return capture_cfg.dnscache.hostname[capture_cfg.dnscache.count - 1];
|
||||
}
|
||||
|
||||
int
|
||||
is_local_address_str(const char *address)
|
||||
{
|
||||
|
|
|
@ -101,21 +101,6 @@ enum capture_storage {
|
|||
typedef struct capture_config capture_config_t;
|
||||
//; Shorter declaration of capture_info structure
|
||||
typedef struct capture_info capture_info_t;
|
||||
//! Shorter declaration of dns_cache structure
|
||||
typedef struct dns_cache dns_cache_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Storage for DNS resolved ips
|
||||
*
|
||||
* Structure to store resolved addresses when capture.lookup
|
||||
* configuration option is enabled.
|
||||
*/
|
||||
struct dns_cache {
|
||||
int count;
|
||||
char addr[ADDRESSLEN][256];
|
||||
char hostname[16][256];
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Capture common configuration
|
||||
|
@ -137,8 +122,6 @@ struct capture_config {
|
|||
struct bpf_program fp;
|
||||
//! libpcap dump file handler
|
||||
pcap_dumper_t *pd;
|
||||
//! Cache for DNS lookups
|
||||
dns_cache_t dnscache;
|
||||
//! Local devices pointer
|
||||
pcap_if_t *devices;
|
||||
//! Capture sources
|
||||
|
@ -441,16 +424,6 @@ dump_packet(pcap_dumper_t *pd, const packet_t *packet);
|
|||
void
|
||||
dump_close(pcap_dumper_t *pd);
|
||||
|
||||
/**
|
||||
* @brief Try to get hostname from its address
|
||||
*
|
||||
* Try to get hostname from the given address, store it in
|
||||
* dnscache. If hostname can not be resolved, then store the
|
||||
* original address to avoid lookup again the same address.
|
||||
*/
|
||||
const char *
|
||||
lookup_hostname(const char *address);
|
||||
|
||||
/**
|
||||
* @brief Check if a given address belongs to a local device
|
||||
*
|
||||
|
|
|
@ -1343,11 +1343,10 @@ call_flow_help(PANEL *panel)
|
|||
mvwprintw(help_win, 16, 2, "F6/R Show original call messages in raw mode");
|
||||
mvwprintw(help_win, 17, 2, "F7/c Cycle between available color modes");
|
||||
mvwprintw(help_win, 18, 2, "F8/C Turn on/off message syntax highlighting");
|
||||
mvwprintw(help_win, 19, 2, "F9/l Turn on/off resolved addresses");
|
||||
mvwprintw(help_win, 20, 2, "9/0 Increase/Decrease raw preview size");
|
||||
mvwprintw(help_win, 21, 2, "t Toggle raw preview display");
|
||||
mvwprintw(help_win, 22, 2, "T Restore raw preview size");
|
||||
mvwprintw(help_win, 23, 2, "D Only show SDP messages");
|
||||
mvwprintw(help_win, 19, 2, "9/0 Increase/Decrease raw preview size");
|
||||
mvwprintw(help_win, 20, 2, "t Toggle raw preview display");
|
||||
mvwprintw(help_win, 21, 2, "T Restore raw preview size");
|
||||
mvwprintw(help_win, 22, 2, "D Only show SDP messages");
|
||||
|
||||
|
||||
// Press any key to close
|
||||
|
|
|
@ -804,10 +804,9 @@ call_list_help(PANEL *panel)
|
|||
mvwprintw(help_win, 18, 2, "F6/R Show selected call messages in raw mode");
|
||||
mvwprintw(help_win, 19, 2, "F7/F Show filter options");
|
||||
mvwprintw(help_win, 20, 2, "F8/c Turn on/off window colours");
|
||||
mvwprintw(help_win, 21, 2, "F9/l Turn on/off resolved addresses");
|
||||
mvwprintw(help_win, 22, 2, "F10/t Select displayed columns");
|
||||
mvwprintw(help_win, 23, 2, "i/I Set display filter to invite");
|
||||
mvwprintw(help_win, 24, 2, "p Stop/Resume packet capture");
|
||||
mvwprintw(help_win, 21, 2, "F10/t Select displayed columns");
|
||||
mvwprintw(help_win, 22, 2, "i/I Set display filter to invite");
|
||||
mvwprintw(help_win, 23, 2, "p Stop/Resume packet capture");
|
||||
|
||||
// Press any key to close
|
||||
wgetch(help_win);
|
||||
|
|
|
@ -235,16 +235,6 @@ call_raw_handle_key(PANEL *panel, int key)
|
|||
// Prev page => N key up strokes
|
||||
info->scroll -= rnpag_steps;
|
||||
break;
|
||||
case ACTION_SHOW_HOSTNAMES:
|
||||
// Tooggle Host/Address display
|
||||
setting_toggle(SETTING_DISPLAY_HOST);
|
||||
// Force refresh panel
|
||||
if (info->group) {
|
||||
call_raw_set_group(info->group);
|
||||
} else {
|
||||
call_raw_set_msg(info->msg);
|
||||
}
|
||||
break;
|
||||
case ACTION_SAVE:
|
||||
if (info->group) {
|
||||
// KEY_S, Display save panel
|
||||
|
|
|
@ -363,9 +363,6 @@ default_handle_key(ui_t *ui, int key)
|
|||
case ACTION_CYCLE_COLOR:
|
||||
setting_toggle(SETTING_COLORMODE);
|
||||
break;
|
||||
case ACTION_SHOW_HOSTNAMES:
|
||||
setting_toggle(SETTING_DISPLAY_HOST);
|
||||
break;
|
||||
case ACTION_SHOW_ALIAS:
|
||||
setting_toggle(SETTING_DISPLAY_ALIAS);
|
||||
break;
|
||||
|
|
|
@ -60,12 +60,10 @@ settings_entry_t entries[] = {
|
|||
{ CAT_SETTINGS_INTERFACE, FLD_SETTINGS_ALTKEY_HINT, SETTING_ALTKEY_HINT, "Alternative keybinding hints .............." },
|
||||
{ CAT_SETTINGS_INTERFACE, FLD_SETTINGS_COLORMODE, SETTING_COLORMODE, "Default message color mode ................" },
|
||||
{ CAT_SETTINGS_INTERFACE, FLD_SETTINGS_EXITPROMPT, SETTING_EXITPROMPT, "Always prompt on quit ....................." },
|
||||
{ CAT_SETTINGS_INTERFACE, FLD_SETTINGS_DISPLAY_HOST, SETTING_DISPLAY_HOST, "Replace addresses with resolved hosts ....." },
|
||||
{ CAT_SETTINGS_INTERFACE, FLD_SETTINGS_DISPLAY_ALIAS, SETTING_DISPLAY_ALIAS, "Replace addresses with alias .............." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_CAPTURE_RTP, SETTING_CAPTURE_RTP, "Capture RTP packets * ....................." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_CAPTURE_LIMIT, SETTING_CAPTURE_LIMIT, "Max dialogs * ............................." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_CAPTURE_DEVICE, SETTING_CAPTURE_DEVICE, "Capture device * .........................." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_CAPTURE_LOOKUP, SETTING_CAPTURE_LOOKUP, "Resolved IP Addresses * ..................." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_SIP_NOINCOMPLETE, SETTING_SIP_NOINCOMPLETE, "Capture full transactions ................." },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_SIP_CALLS, SETTING_SIP_CALLS, "Only capture calls * ......................" },
|
||||
{ CAT_SETTINGS_CAPTURE, FLD_SETTINGS_SAVEPATH, SETTING_SAVEPATH, "Default Save path ........................." },
|
||||
|
|
|
@ -70,8 +70,6 @@ enum settings_field_list {
|
|||
FLD_SETTINGS_COLORMODE_LB,
|
||||
FLD_SETTINGS_EXITPROMPT,
|
||||
FLD_SETTINGS_EXITPROMPT_LB,
|
||||
FLD_SETTINGS_DISPLAY_HOST,
|
||||
FLD_SETTINGS_DISPLAY_HOST_LB,
|
||||
FLD_SETTINGS_DISPLAY_ALIAS,
|
||||
FLD_SETTINGS_DISPLAY_ALIAS_LB,
|
||||
FLD_SETTINGS_CAPTURE_RTP,
|
||||
|
@ -80,8 +78,6 @@ enum settings_field_list {
|
|||
FLD_SETTINGS_CAPTURE_LIMIT_LB,
|
||||
FLD_SETTINGS_CAPTURE_DEVICE,
|
||||
FLD_SETTINGS_CAPTURE_DEVICE_LB,
|
||||
FLD_SETTINGS_CAPTURE_LOOKUP,
|
||||
FLD_SETTINGS_CAPTURE_LOOKUP_LB,
|
||||
FLD_SETTINGS_SIP_NOINCOMPLETE,
|
||||
FLD_SETTINGS_SIP_NOINCOMPLETE_LB,
|
||||
FLD_SETTINGS_SIP_CALLS,
|
||||
|
|
|
@ -58,7 +58,6 @@ key_binding_t bindings[ACTION_SENTINEL] = {
|
|||
{ ACTION_TOGGLE_SYNTAX, "togglesyntax", { KEY_F(8), 'C' }, 2 },
|
||||
{ ACTION_CYCLE_COLOR, "colormode", { 'c' }, 1 },
|
||||
{ ACTION_COMPRESS, "compress", { 's' }, 1 },
|
||||
{ ACTION_SHOW_HOSTNAMES, "togglehostname", { KEY_F(9) }, 1 },
|
||||
{ ACTION_SHOW_ALIAS, "togglealias", { 'a' }, 1 },
|
||||
{ ACTION_TOGGLE_PAUSE, "pause", { 'p' }, 1 },
|
||||
{ ACTION_PREV_SCREEN, "prevscreen", { KEY_ESC, 'q', 'Q' }, 3 },
|
||||
|
|
|
@ -44,7 +44,6 @@ setting_t settings[SETTING_COUNT] = {
|
|||
{ SETTING_ALTKEY_HINT, "hintkeyalt", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_EXITPROMPT, "exitprompt", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_CAPTURE_LIMIT, "capture.limit", SETTING_FMT_NUMBER, "20000", NULL },
|
||||
{ SETTING_CAPTURE_LOOKUP, "capture.lookup", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_CAPTURE_DEVICE, "capture.device", SETTING_FMT_STRING, "any", NULL },
|
||||
{ SETTING_CAPTURE_OUTFILE, "capture.outfile", SETTING_FMT_STRING, "", NULL },
|
||||
{ SETTING_CAPTURE_KEYFILE, "capture.keyfile", SETTING_FMT_STRING, "", NULL },
|
||||
|
@ -53,7 +52,6 @@ setting_t settings[SETTING_COUNT] = {
|
|||
{ SETTING_SIP_NOINCOMPLETE, "sip.noincomplete", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_SIP_CALLS, "sip.calls", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_SAVEPATH, "savepath", SETTING_FMT_STRING, "", NULL },
|
||||
{ SETTING_DISPLAY_HOST, "displayhost", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_DISPLAY_ALIAS, "displayalias", SETTING_FMT_ENUM, SETTING_OFF, SETTING_ENUM_ONOFF },
|
||||
{ SETTING_CL_SCROLLSTEP, "cl.scrollstep", SETTING_FMT_NUMBER, "4", NULL },
|
||||
{ SETTING_CL_COLORATTR, "cl.colorattr", SETTING_FMT_ENUM, SETTING_ON, SETTING_ENUM_ONOFF },
|
||||
|
|
|
@ -75,7 +75,6 @@ enum setting_id {
|
|||
SETTING_ALTKEY_HINT,
|
||||
SETTING_EXITPROMPT,
|
||||
SETTING_CAPTURE_LIMIT,
|
||||
SETTING_CAPTURE_LOOKUP,
|
||||
SETTING_CAPTURE_DEVICE,
|
||||
SETTING_CAPTURE_OUTFILE,
|
||||
SETTING_CAPTURE_KEYFILE,
|
||||
|
@ -84,7 +83,6 @@ enum setting_id {
|
|||
SETTING_SIP_NOINCOMPLETE,
|
||||
SETTING_SIP_CALLS,
|
||||
SETTING_SAVEPATH,
|
||||
SETTING_DISPLAY_HOST,
|
||||
SETTING_DISPLAY_ALIAS,
|
||||
SETTING_CL_SCROLLSTEP,
|
||||
SETTING_CL_COLORATTR,
|
||||
|
|
|
@ -717,8 +717,6 @@ sip_address_format(const char *address)
|
|||
// Return address formatted depending on active settings
|
||||
if (setting_enabled(SETTING_DISPLAY_ALIAS)) {
|
||||
return get_alias_value(address);
|
||||
} else if (setting_enabled(SETTING_DISPLAY_HOST)) {
|
||||
return lookup_hostname(address);
|
||||
} else {
|
||||
return address;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue