Changeset dc45afd20f32e3709eed851f05359dea25e5b2b7

Show
Ignore:
Timestamp:
03/05/08 04:52:59 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1204692779 +0000
git-parent:

[4330e3d7e1aa02f7bfd1892c3294b652c79ce3a5]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1204692779 +0000
Message:

Allow 'port' config option

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/ssh2.c

    r4330e3d rdc45afd  
    1919 
    2020#include <libssh2.h> 
     21 
     22#define DEFAULT_SSH_PORT 22 
    2123 
    2224typedef struct { 
     
    190192  } sockaddr; 
    191193  socklen_t sockaddr_len; 
     194  unsigned short ssh_port = DEFAULT_SSH_PORT; 
     195  const char *port_str; 
    192196  long on; 
    193197 
     
    215219  if(ioctl(fd, FIONBIO, &on)) goto fail; 
    216220 
     221  if(noit_hash_retrieve(check->config, "port", strlen("port"), 
     222                        (void **)&port_str)) { 
     223    ssh_port = (unsigned short)atoi(port_str); 
     224  } 
    217225  memset(&sockaddr, 0, sizeof(sockaddr)); 
    218226  sockaddr.sin6.sin6_family = check->target_family; 
     
    220228    memcpy(&sockaddr.sin.sin_addr, 
    221229           &check->target_addr.addr, sizeof(sockaddr.sin.sin_addr)); 
    222     sockaddr.sin.sin_port = htons(22); 
     230    sockaddr.sin.sin_port = htons(ssh_port); 
    223231    sockaddr_len = sizeof(sockaddr.sin); 
    224232  } 
     
    226234    memcpy(&sockaddr.sin6.sin6_addr, 
    227235           &check->target_addr.addr6, sizeof(sockaddr.sin6.sin6_addr)); 
    228     sockaddr.sin6.sin6_port = htons(22); 
     236    sockaddr.sin6.sin6_port = htons(ssh_port); 
    229237    sockaddr_len = sizeof(sockaddr.sin6); 
    230238  }