diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f2bf3bd495..6c532d08af 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2011-02-01 00:32 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbnetio/utils/hbnetio/netiosrv.prg + * contrib/hbnetio/utils/hbnetio/netiocon.prg + + Added console commands to add/remove filters. + + Added rpc and console commands to list filters. + 2011-01-31 22:50 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/hbfilehi.prg + PATHNORMALIZE(): Will now strip double pathseps, except the @@ -238,7 +244,7 @@ + src/rtl/base64d.c + Replaced HB_BASE64DECODE() with an optimized C implementation. The core code is borrowed from libb64 project - (http://sourceforge.net/projects/libb64) and has been places + (http://sourceforge.net/projects/libb64) and has been placed to public domain by author Chris Venter. I've reformatted the code and made some minor modifications. I had used the Harbour license for the whole file. diff --git a/harbour/contrib/hbnetio/utils/hbnetio/netiocon.prg b/harbour/contrib/hbnetio/utils/hbnetio/netiocon.prg index 5cf886c705..470fbf6f13 100644 --- a/harbour/contrib/hbnetio/utils/hbnetio/netiocon.prg +++ b/harbour/contrib/hbnetio/utils/hbnetio/netiocon.prg @@ -56,23 +56,33 @@ PROCEDURE hbnetiocon_cmdUI( cIP, nPort, cPassword ) nHistIndex := Len( aHistory ) + 1 hCommands := { ; - "?" => { "" , "Synonym for 'help'." , {|| cmdHelp( hCommands ) } },; - "exit" => { "" , "Exit console." , {|| lQuit := .T. } },; - "clear" => { "" , "Clear screen." , {|| Scroll(), SetPos( 0, 0 ) } },; - "connect" => { "[]]" , "Connect." , {| cCommand | cmdConnect( cCommand, @pConnection, @cIP, @nPort ) } },; - "disconnect" => { "" , "Disconnect." , {|| cmdDisconnect( @pConnection ) } },; - "sysinfo" => { "" , "Show system/build information." , {|| cmdSysInfo( pConnection ) } },; - "showconf" => { "" , "Show server configuration." , {|| cmdServerConfig( pConnection ) } },; - "show" => { "" , "Show list of connections." , {|| cmdConnInfo( pConnection, .F. ) } },; - "showadmin" => { "" , "Show list of management connections." , {|| cmdConnInfo( pConnection, .T. ) } },; - "noconn" => { "" , "Disable incoming connections." , {|| cmdConnEnable( pConnection, .F. ) } },; - "conn" => { "" , "Enable incoming connections." , {|| cmdConnEnable( pConnection, .T. ) } },; - "nologconn" => { "" , "Disable logging incoming connections." , {|| cmdConnLogEnable( pConnection, .F. ) } },; - "logconn" => { "" , "Enable logging incoming connections." , {|| cmdConnLogEnable( pConnection, .T. ) } },; - "stop" => { "[|all]", "Stop specified connection(s)." , {| cCommand | cmdConnStop( pConnection, cCommand ) } },; - "clientinfo" => { "[" , "Show client details." , {| cCommand | cmdConnClientInfo( pConnection, cCommand ) } },; - "quit" => { "" , "Stop server and exit console." , {|| cmdShutdown( pConnection ), lQuit := .T. } },; - "help" => { "" , "Display this help." , {|| cmdHelp( hCommands ) } } } + "?" => { "" , "Synonym for 'help'." , {|| cmdHelp( hCommands ) } },; + "exit" => { "" , "Exit console." , {|| lQuit := .T. } },; + "clear" => { "" , "Clear screen." , {|| Scroll(), SetPos( 0, 0 ) } },; + "connect" => { "[]]" , "Connect." , {| cCommand | cmdConnect( cCommand, @pConnection, @cIP, @nPort ) } },; + "disconnect" => { "" , "Disconnect." , {|| cmdDisconnect( @pConnection ) } },; + "sysinfo" => { "" , "Show system/build information." , {|| cmdSysInfo( pConnection ) } },; + "showconf" => { "" , "Show server configuration." , {|| cmdServerConfig( pConnection ) } },; + "show" => { "" , "Show list of connections." , {|| cmdConnInfo( pConnection, .F. ) } },; + "showadmin" => { "" , "Show list of management connections." , {|| cmdConnInfo( pConnection, .T. ) } },; + "noconn" => { "" , "Disable incoming connections." , {|| cmdConnEnable( pConnection, .F. ) } },; + "conn" => { "" , "Enable incoming connections." , {|| cmdConnEnable( pConnection, .T. ) } },; + "nologconn" => { "" , "Disable logging incoming connections." , {|| cmdConnLogEnable( pConnection, .F. ) } },; + "logconn" => { "" , "Enable logging incoming connections." , {|| cmdConnLogEnable( pConnection, .T. ) } },; + "filt" => { "" , "Show filters." , {|| cmdConnFilters( pConnection, .F. ) } },; + "filtadmin" => { "" , "Show filters for management connections." , {|| cmdConnFilters( pConnection, .T. ) } },; + "allowadd" => { "" , "Add allow filter" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_allowadd" ) } },; + "allowdel" => { "" , "Remove allow filter" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_allowdel" ) } },; + "blockadd" => { "" , "Add block filter" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_blockadd" ) } },; + "blockdel" => { "" , "Remove block filter" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_blockdel" ) } },; + "allowaddadmin" => { "" , "Add allow filter for management connections" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_allowaddadmin" ) } },; + "allowdeladmin" => { "" , "Remove allow filter for management connections" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_allowdeladmin" ) } },; + "blockaddadmin" => { "" , "Add block filter for management connections" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_blockaddadmin" ) } },; + "blockdeladmin" => { "" , "Remove block filter for management connections" , {| cCommand | cmdConnFilterMod( pConnection, cCommand, "hbnetiomgm_blockdeladmin" ) } },; + "stop" => { "[|all]", "Stop specified connection(s)." , {| cCommand | cmdConnStop( pConnection, cCommand ) } },; + "clientinfo" => { "[" , "Show client details." , {| cCommand | cmdConnClientInfo( pConnection, cCommand ) } },; + "quit" => { "" , "Stop server and exit console." , {|| cmdShutdown( pConnection ), lQuit := .T. } },; + "help" => { "" , "Display this help." , {|| cmdHelp( hCommands ) } } } lQuit := .F. @@ -520,3 +530,40 @@ STATIC PROCEDURE cmdConnLogEnable( pConnection, lValue ) ENDIF RETURN + +STATIC PROCEDURE cmdConnFilterMod( pConnection, cCommand, cRPC ) + LOCAL aToken + + IF Empty( pConnection ) + QQOut( "Not connected.", hb_eol() ) + ELSE + aToken := hb_ATokens( cCommand, " " ) + IF Len( aToken ) > 1 + IF netio_funcexec( pConnection, cRPC, aToken[ 1 ] ) + QQOut( "Done", hb_eol() ) + ELSE + QQOut( "Failed", hb_eol() ) + ENDIF + ELSE + QQOut( "Error: Invalid syntax.", hb_eol() ) + ENDIF + ENDIF + + RETURN + +STATIC PROCEDURE cmdConnFilters( pConnection, lManagement ) + LOCAL aArray + LOCAL hFilter + + IF Empty( pConnection ) + QQOut( "Not connected.", hb_eol() ) + ELSE + aArray := netio_funcexec( pConnection, iif( lManagement, "hbnetiomgm_filtersadmin", "hbnetiomgm_filters" ) ) + + FOR EACH hFilter IN aArray + QQOut( hFilter[ "cType" ],; + hFilter[ "cAddress" ], hb_eol() ) + NEXT + ENDIF + + RETURN diff --git a/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg b/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg index ceee585d28..710a585d8d 100644 --- a/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg +++ b/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg @@ -221,6 +221,8 @@ PROCEDURE Main( ... ) "hbnetiomgm_allowdeladmin" => {| ... | netiomgm_rpc_filtermod( netiomgm, netiomgm[ _NETIOSRV_hAllow ], .F., ... ) } ,; "hbnetiomgm_blockaddadmin" => {| ... | netiomgm_rpc_filtermod( netiomgm, netiomgm[ _NETIOSRV_hBlock ], .T., ... ) } ,; "hbnetiomgm_blockdeladmin" => {| ... | netiomgm_rpc_filtermod( netiomgm, netiomgm[ _NETIOSRV_hBlock ], .F., ... ) } ,; + "hbnetiomgm_filters" => {| ... | netiomgm_rpc_filters( netiosrv ) } ,; + "hbnetiomgm_filtersadmin" => {| ... | netiomgm_rpc_filters( netiomgm ) } ,; "hbnetiomgm_stop" => {| ... | netiomgm_rpc_stop( netiosrv, ... ) } ,; "hbnetiomgm_conn" => {| ... | netiomgm_rpc_conn( netiosrv, .T. ) } ,; "hbnetiomgm_noconn" => {| ... | netiomgm_rpc_conn( netiosrv, .F. ) } ,; @@ -620,6 +622,27 @@ STATIC FUNCTION netiomgm_rpc_filtermod( netiosrv, hList, lAdd, cAddress ) RETURN lSuccess +STATIC FUNCTION netiomgm_rpc_filters( netiosrv ) + LOCAL cType + LOCAL hFilter + LOCAL cAddress + + LOCAL aArray := {} + + hb_mutexLock( netiosrv[ _NETIOSRV_mtxFilters ] ) + + FOR EACH cType, hFilter IN { "allow", "block" }, { netiosrv[ _NETIOSRV_hAllow ], netiosrv[ _NETIOSRV_hBlock ] } + FOR EACH cAddress IN hFilter + AAdd( aArray, {; + "cType" => cType,; + "cAddress" => cAddress:__enumKey() } ) + NEXT + NEXT + + hb_mutexUnlock( netiosrv[ _NETIOSRV_mtxFilters ] ) + + RETURN aArray + STATIC FUNCTION ConnStatusStr( nStatus ) SWITCH nStatus