Merge pull request #6 from jweslley/master

minor improvements
This commit is contained in:
Claudemiro
2016-01-27 09:10:52 -02:00
4 changed files with 28 additions and 4 deletions
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=Ipe
After=syslog.target network.target
[Service]
Type=simple
User=ipe
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ipe
ExecStart=/path/to/ipe -logtostderr -config="path_to_config.json"
[Install]
WantedBy=multi-user.target
+3 -2
View File
@@ -11,6 +11,7 @@ import (
"sync"
"time"
"github.com/dimiro1/ipe/utils"
log "github.com/golang/glog"
)
@@ -40,12 +41,12 @@ func (c *channel) IsPublic() bool {
// Check if the type of the channel is presence
func (c *channel) IsPresence() bool {
return strings.HasPrefix(c.ChannelID, "presence-")
return utils.IsPresenceChannel(c.ChannelID)
}
// Check if the type of the channel is private
func (c *channel) IsPrivate() bool {
return strings.HasPrefix(c.ChannelID, "private-")
return utils.IsPrivateChannel(c.ChannelID)
}
// Get the total of subscribers
+2 -2
View File
@@ -123,8 +123,8 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses
break
}
isPresence := strings.HasPrefix(channelName, "presence-")
isPrivate := strings.HasPrefix(channelName, "private-")
isPresence := utils.IsPresenceChannel(channelName)
isPrivate := utils.IsPrivateChannel(channelName)
if isPresence || isPrivate {
toSign := []string{connection.SocketID, channelName}
+9
View File
@@ -12,6 +12,7 @@ import (
"math"
"math/rand"
"regexp"
"strings"
)
var validChannelName *regexp.Regexp
@@ -38,3 +39,11 @@ func GenerateSessionID() string {
func IsChannelNameValid(channelName string) bool {
return validChannelName.Match([]byte(channelName))
}
func IsPrivateChannel(channelName string) bool {
return strings.HasPrefix(channelName, "private-")
}
func IsPresenceChannel(channelName string) bool {
return strings.HasPrefix(channelName, "presence-")
}