Ocean/ICCC/HTTPConnector.go
Thorsten Sommer a007db1b79 Bug fixes and improvements
+ Add a function to the Tools package to provide the local IP address
and port
+ Add a function to the Tools package to provide a time as formated
string as yyyyMMdd hhmmss.fff
+ Improved the ICCC startup message: Now, the message contains the IP
address and port of the stared server
+ Add a new configuration to specific the necessary Ocean servers' port
(internally, not the public port)
+ The template package reports now which version out of the grid FS is
used.
+ The Ocean server is now bound to the correct IP address and port
(rule: the local IP address!)
+ The order of the system shutdown handlers were wrong!
+ The early ICCC messages problem is now fixed!
+ Fixed an ICCC bug for the case, that a message does not have any
payload!
+ Also the configuration database uses now the correct mgo MongoDB rules
(SetSafe & SetMode)
2014-06-08 11:35:01 +02:00

42 lines
1.7 KiB
Go

package ICCC
import "fmt"
import "net/http"
import "github.com/SommerEngineering/Ocean/Tools"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
func ICCCHandler(response http.ResponseWriter, request *http.Request) {
if errParse := request.ParseForm(); errParse != nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameNETWORK, `Was not able to parse the HTTP form data from an ICCC message!`)
http.NotFound(response, request)
return
}
messageData := map[string][]string(request.PostForm)
if len(messageData) < 3 {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameNETWORK, `The ICCC message contains not enough data: At least the channel, command and password is required!`)
http.NotFound(response, request)
return
}
channel := messageData[`channel`][0]
command := messageData[`command`][0]
password := messageData[`InternalCommPassword`][0]
if password != Tools.InternalCommPassword() {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityCritical, LM.ImpactNone, LM.MessageNamePASSWORD, `Received a ICCC message with wrong password!`, request.RemoteAddr)
http.NotFound(response, request)
return
}
key := fmt.Sprintf(`%s::%s`, channel, command)
listener := listeners[key]
if listener == nil {
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelWARN, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to find the correct listener for these ICCC message.`, `channel=`+channel, `command`+command, `hostname=`+Tools.ThisHostname())
} else {
listener(messageData)
}
}