Compare commits
3 Commits
v1.0.0-rc
...
v1.0.0-rc1
Author | SHA1 | Date | |
---|---|---|---|
365b7b9792 | |||
b2fff3789b | |||
b9807f0ba7 |
30
LICENSE
Normal file
30
LICENSE
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
Copyright (C) 2020, yo000 <johan@nosd.in>
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
- Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
- Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
- Neither the name of the Mumble Developers nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from this
|
||||||
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
`AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
@ -5,3 +5,5 @@ ldapUser cn=mynettcptable,ou=services,dc=example,dc=org
|
|||||||
ldapPass here_lies_the_password
|
ldapPass here_lies_the_password
|
||||||
# networks cache refresh interval
|
# networks cache refresh interval
|
||||||
refresh 300
|
refresh 300
|
||||||
|
# Inactive connection timeout
|
||||||
|
timeout 30
|
||||||
|
@ -7,22 +7,22 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"os"
|
||||||
// "log"
|
// "log"
|
||||||
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
|
"log/syslog"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"errors"
|
|
||||||
"strings"
|
|
||||||
"log/syslog"
|
|
||||||
|
|
||||||
"github.com/tabalt/pidfile"
|
|
||||||
"github.com/go-ldap/ldap/v3"
|
"github.com/go-ldap/ldap/v3"
|
||||||
"github.com/peterbourgon/ff"
|
"github.com/peterbourgon/ff"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
|
lSyslog "github.com/sirupsen/logrus/hooks/syslog"
|
||||||
|
"github.com/tabalt/pidfile"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -95,7 +95,6 @@ func unsetNetCachePresentFlag() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func buildNetCacheFromIPNetwork(conLdap *ldap.Conn) error {
|
func buildNetCacheFromIPNetwork(conLdap *ldap.Conn) error {
|
||||||
attribute := "ipNetworkNumber"
|
attribute := "ipNetworkNumber"
|
||||||
|
|
||||||
@ -117,10 +116,6 @@ func buildNetCacheFromIPNetwork(conLdap *ldap.Conn) error {
|
|||||||
logstream.Info(fmt.Sprintf("Error searching into LDAP: Attribute %s not found for entry %s\n", attribute, r))
|
logstream.Info(fmt.Sprintf("Error searching into LDAP: Attribute %s not found for entry %s\n", attribute, r))
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
// Explode the network to individual IPs
|
|
||||||
// 1: Verify format : Either CIDR, or netmask is in ipNetworkMask (do we want to support this?)
|
|
||||||
// 2: n := iplib.NewNet4(net.ParseIP("192.168.0.0"), 16)
|
|
||||||
// n.Enumerate(
|
|
||||||
_, ipnet, err := net.ParseCIDR(r.Attributes[0].Values[0])
|
_, ipnet, err := net.ParseCIDR(r.Attributes[0].Values[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logstream.Info(err.Error())
|
logstream.Info(err.Error())
|
||||||
@ -143,7 +138,6 @@ func buildNetCacheFromIPNetwork(conLdap *ldap.Conn) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func isIPContainedInNetCache(string_ip string) (bool, error) {
|
func isIPContainedInNetCache(string_ip string) (bool, error) {
|
||||||
ip := net.ParseIP(string_ip)
|
ip := net.ParseIP(string_ip)
|
||||||
if ip == nil {
|
if ip == nil {
|
||||||
@ -391,7 +385,7 @@ func main() {
|
|||||||
if strings.EqualFold(*logTo, "syslog") {
|
if strings.EqualFold(*logTo, "syslog") {
|
||||||
// level != priority
|
// level != priority
|
||||||
prio := syslog.LOG_MAIL
|
prio := syslog.LOG_MAIL
|
||||||
switch (*logLevel) {
|
switch *logLevel {
|
||||||
case "fatal":
|
case "fatal":
|
||||||
prio += syslog.LOG_CRIT
|
prio += syslog.LOG_CRIT
|
||||||
case "error":
|
case "error":
|
||||||
@ -422,4 +416,3 @@ func main() {
|
|||||||
logstream.Infof("Start listening for incoming connections on %s\n", *listen)
|
logstream.Infof("Start listening for incoming connections on %s\n", *listen)
|
||||||
run()
|
run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user