def _openbsd_remotes_on(port, which_end):
 remotes = set()
 try:
  data = subprocess.check_output(['netstat', '-nf', 'inet'])
 except subprocess.CalledProcessError:
  log.error('Failed netstat')
  raise
 lines = data.split('\n')
 for line in lines:
  if ('ESTABLISHED' not in line):
   continue
  chunks = line.split()
  (local_host, local_port) = chunks[3].rsplit('.', 1)
  (remote_host, remote_port) = chunks[4].rsplit('.', 1)
  if ((which_end == 'remote_port') and (int(remote_port) != port)):
   continue
  if ((which_end == 'local_port') and (int(local_port) != port)):
   continue
  remotes.add(remote_host)
 return remotes

def _openbsd_remotes_on ( port , which_end ) : remotes = set ( ) try : data = subprocess . check_output ( [ 'netstat' , '-nf' , 'inet' ] ) except subprocess . CalledProcessError : log . error ( 'Failed netstat' ) raise lines = data . split ( '\n' ) for line in lines : if ( 'ESTABLISHED' not in line ) : continue chunks = line . split ( ) ( local_host , local_port ) = chunks [ 3 ] . rsplit ( '.' , 1 ) ( remote_host , remote_port ) = chunks [ 4 ] . rsplit ( '.' , 1 ) if ( ( which_end == 'remote_port' ) and ( int ( remote_port ) != port ) ) : continue if ( ( which_end == 'local_port' ) and ( int ( local_port ) != port ) ) : continue remotes . add ( remote_host ) return remotes
openbsd specific helper function .