diff options
author | charleszlu <c4planted@gmail.com> | 2019-05-13 14:29:03 +0300 |
---|---|---|
committer | charleszlu <c4planted@gmail.com> | 2019-05-13 14:29:03 +0300 |
commit | 6e298e8a7ab8338b355027797e28a3b2b19f950e (patch) | |
tree | 090744626b20710d68836710c519710c84f5d7e3 | |
parent | b005f6be04c87e5738c0adff3013a71cea652dd3 (diff) |
Added exlude keywords
-rw-r--r-- | Dockerfile | 13 | ||||
-rw-r--r-- | murmur-info.py | 14 |
2 files changed, 18 insertions, 9 deletions
@@ -2,6 +2,7 @@ FROM goozler/zeroc_ice_python RUN apk --update add --upgrade --no-cache openssh bash tzdata +# openssh server based on hermsi/alpine-sshd: https://github.com/Hermsi1337/docker-sshd COPY entrypoint.sh /entrypoint.sh COPY Murmur.ice /murmur-info/Murmur.ice COPY murmur-info.py /murmur-info/murmur-info.py @@ -10,9 +11,15 @@ RUN chmod +x /entrypoint.sh \ && mkdir -p /root/.ssh \ && rm -rf /var/cache/apk/* /tmp/* -ENV OPENSSH_VERSION=${OPENSSH_VERSION} \ - ROOT_PASSWORD=root \ - KEYPAIR_LOGIN=false +ENV ROOT_PASSWORD root +ENV KEYPAIR_LOGIN false +ENV MURMUR_ICE_PATH /murmur-info/Murmur.ice +ENV MURMUR_HOST 127.0.0.1 +ENV MURMUR_ICE_PORT 6502 +ENV MURMUR_ICE_SECRET "" +ENV MURMUR_ICE_MSG_SIZE_MAX 65535 +ENV EXCLUDE_KEYWORDS "" + VOLUME ["/etc/ssh"] diff --git a/murmur-info.py b/murmur-info.py index a2a0b42..1639e10 100644 --- a/murmur-info.py +++ b/murmur-info.py @@ -34,15 +34,15 @@ # 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. -import Ice, sys, os +import Ice, sys, os, ast class MurmurIce: - def __init__(self, murmur_ice_path, murmur_host, murmur_icesecreatread, ice_port=6502, message_size_max=65535): + def __init__(self, murmur_ice_path, murmur_host, murmur_icesecreatread, ice_port=6502, message_size_max=65535, exclude_keywords=[]): # Exclude names containing these keywords from being counted as users. # Useful for excluding bots - self.exclude_keywords=["Delay","BBUBot","PeiPeiBot"] + self.exclude_keywords=exclude_keywords # Path to Slice and Murmur.ice Ice.loadSlice(f"--all -I{Ice.getSliceDir()} {murmur_ice_path}") @@ -96,7 +96,7 @@ class MurmurIce: # also count not authenticated users (who are not excluded) for user in self.users.values(): for keyword in self.exclude_keywords: - if keyword in user.name: + if str(keyword).lower() in user.name.lower(): self.excludedusers += 1 break else: @@ -153,10 +153,11 @@ if __name__ == "__main__": ice_port = os.getenv('MURMUR_ICE_PORT', 6502) murmur_icesecreatread = os.getenv('MURMUR_ICE_SECRET') message_size_max = os.getenv('MURMUR_ICE_MSG_SIZE_MAX', 65535) + exclude_keywords = ast.literal_eval('['+os.getenv('EXCLUDE_KEYWORDS', '')+']') - if murmur_ice_path is None: + if not murmur_ice_path: raise RuntimeError('MURMUR_ICE_PATH environment variable is not set!') - if murmur_icesecreatread is None: + if not murmur_icesecreatread: raise RuntimeError('MURMUR_ICE_SECRET environment variable is not set!') murmur = MurmurIce( @@ -165,6 +166,7 @@ if __name__ == "__main__": murmur_icesecreatread=murmur_icesecreatread, ice_port=ice_port, message_size_max=message_size_max, + exclude_keywords=exclude_keywords ) # Usage |