@@ -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
@@ -11,6 +11,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dimiro1/ipe/utils"
|
||||||
log "github.com/golang/glog"
|
log "github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,12 +41,12 @@ func (c *channel) IsPublic() bool {
|
|||||||
|
|
||||||
// Check if the type of the channel is presence
|
// Check if the type of the channel is presence
|
||||||
func (c *channel) IsPresence() bool {
|
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
|
// Check if the type of the channel is private
|
||||||
func (c *channel) IsPrivate() bool {
|
func (c *channel) IsPrivate() bool {
|
||||||
return strings.HasPrefix(c.ChannelID, "private-")
|
return utils.IsPrivateChannel(c.ChannelID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the total of subscribers
|
// Get the total of subscribers
|
||||||
|
|||||||
+2
-2
@@ -123,8 +123,8 @@ func onMessage(conn *websocket.Conn, w http.ResponseWriter, r *http.Request, ses
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
isPresence := strings.HasPrefix(channelName, "presence-")
|
isPresence := utils.IsPresenceChannel(channelName)
|
||||||
isPrivate := strings.HasPrefix(channelName, "private-")
|
isPrivate := utils.IsPrivateChannel(channelName)
|
||||||
|
|
||||||
if isPresence || isPrivate {
|
if isPresence || isPrivate {
|
||||||
toSign := []string{connection.SocketID, channelName}
|
toSign := []string{connection.SocketID, channelName}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var validChannelName *regexp.Regexp
|
var validChannelName *regexp.Regexp
|
||||||
@@ -38,3 +39,11 @@ func GenerateSessionID() string {
|
|||||||
func IsChannelNameValid(channelName string) bool {
|
func IsChannelNameValid(channelName string) bool {
|
||||||
return validChannelName.Match([]byte(channelName))
|
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-")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user