├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .hadolint.yaml ├── .hound.yml ├── CONTRIBUTING.md ├── Dockerfile.nipapd ├── Dockerfile.www ├── INSTALL ├── LICENSE ├── Makefile ├── NEWS ├── README.md ├── ca_certs └── README.rst ├── docs ├── INSTALL.rst ├── LICENSE ├── Makefile ├── README.logging ├── config-cli.rst ├── config-nipapd.rst ├── config-www.rst ├── getting-started-development.rst ├── install-debian.rst ├── install-unix.rst ├── release-handling.rst └── sphinx │ ├── Makefile │ ├── README │ ├── authlib.rst │ ├── conf.py │ ├── design.rst │ ├── index.rst │ ├── nipap.rst │ ├── pynipap.rst │ ├── release-handling.rst │ ├── requirements.txt │ └── xmlrpc.rst ├── jnipap ├── .gitignore ├── Makefile ├── README.rst ├── build.gradle └── src │ ├── main │ └── java │ │ └── jnipap │ │ ├── AddPrefixOptions.java │ │ ├── AuthFailedException.java │ │ ├── Connection.java │ │ ├── ConnectionException.java │ │ ├── DuplicateException.java │ │ ├── InputException.java │ │ ├── InvalidParameterException.java │ │ ├── Jnipap.java │ │ ├── JnipapException.java │ │ ├── MissingInputException.java │ │ ├── NonExNullParser.java │ │ ├── NonExistentException.java │ │ ├── Pool.java │ │ ├── Prefix.java │ │ ├── VRF.java │ │ └── ValueException.java │ └── test │ └── java │ └── JnipapTester.java ├── nipap-cli ├── MANIFEST.in ├── Makefile ├── README.rst ├── bash_complete ├── debian │ ├── changelog │ ├── control │ ├── copyright │ ├── install │ ├── nipap-cli.bash-completion │ ├── nipap.manpages │ ├── postinst │ ├── postrm │ ├── rules │ └── source │ │ ├── format │ │ └── options ├── helper-nipap ├── nipap ├── nipap.man.rst ├── nipap_cli │ ├── __init__.py │ ├── command.py │ └── nipap_cli.py ├── nipaprc ├── pyproject.toml ├── requirements.txt ├── setup.py └── tests │ └── cli-test.py ├── nipap-www ├── MANIFEST.in ├── Makefile ├── debian │ ├── changelog │ ├── config │ ├── control │ ├── copyright │ ├── install │ ├── postinst │ ├── preinst │ ├── py3dist-overrides │ ├── rules │ ├── source │ │ ├── format │ │ └── options │ └── templates ├── entrypoint.sh ├── nipap-www.wsgi ├── nipapwww │ ├── __init__.py │ ├── auth.py │ ├── ng.py │ ├── prefix.py │ ├── static.py │ ├── static │ │ ├── Chart.min.js │ │ ├── angular-1.7.2.min.js │ │ ├── angular-route-1.7.2.min.js │ │ ├── app.js │ │ ├── controllers.js │ │ ├── css │ │ │ ├── bootstrap-3.2.0.min.css │ │ │ ├── jquery-ui-1.12.1.min.css │ │ │ ├── jquery.tagit.css │ │ │ ├── ng-tags-input-2.1.1.min.css │ │ │ └── nipap.css │ │ ├── directives.js │ │ ├── favicon.ico │ │ ├── filters.js │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ └── glyphicons-halflings-regular.woff │ │ ├── images │ │ │ ├── add_prefix_from_pool_notice.png │ │ │ ├── add_prefix_from_prefix_notice.png │ │ │ ├── back_disabled.jpg │ │ │ ├── back_enabled.jpg │ │ │ ├── comments-16.png │ │ │ ├── display_menu.png │ │ │ ├── expand_pool_notice.png │ │ │ ├── forward_disabled.jpg │ │ │ ├── forward_enabled.jpg │ │ │ ├── loading.gif │ │ │ ├── sort_asc.png │ │ │ ├── sort_asc_disabled.png │ │ │ ├── sort_both.png │ │ │ ├── sort_desc.png │ │ │ ├── sort_desc_disabled.png │ │ │ ├── tag-16.png │ │ │ ├── ui-icons_444444_256x240.png │ │ │ ├── ui-icons_555555_256x240.png │ │ │ ├── ui-icons_777620_256x240.png │ │ │ ├── ui-icons_777777_256x240.png │ │ │ ├── ui-icons_cc0000_256x240.png │ │ │ ├── ui-icons_ffffff_256x240.png │ │ │ └── x-mark-3-16.png │ │ ├── jquery-3.3.1.min.js │ │ ├── jquery-ui-1.12.1.min.js │ │ ├── jquery.url.js │ │ ├── ng-infinite-scroll.min.js │ │ ├── ng-tags-input-2.1.1.min.js │ │ ├── nipap.js │ │ ├── services.js │ │ ├── tag-it.min.js │ │ ├── templates │ │ │ ├── pool_add.html │ │ │ ├── pool_edit.html │ │ │ ├── pool_form.html │ │ │ ├── pool_list.html │ │ │ ├── pool_selector.html │ │ │ ├── pool_selector_popup.html │ │ │ ├── prefix_add.html │ │ │ ├── prefix_edit.html │ │ │ ├── prefix_form.html │ │ │ ├── vrf_add.html │ │ │ ├── vrf_edit.html │ │ │ ├── vrf_form.html │ │ │ ├── vrf_list.html │ │ │ └── vrf_selector.html │ │ └── ui-bootstrap-tpls-1.3.3.min.js │ ├── templates │ │ ├── base.html │ │ ├── login.html │ │ ├── macros.html │ │ ├── ng-pool.html │ │ ├── ng-prefix.html │ │ ├── ng-vrf.html │ │ ├── prefix_list.html │ │ └── version.html │ ├── tracing.py │ ├── version.py │ └── xhr.py ├── pyproject.toml └── setup.py ├── nipap ├── MANIFEST.in ├── Makefile ├── README.rst ├── debian │ ├── changelog │ ├── control │ ├── copyright │ ├── nipap-common.install │ ├── nipapd.config │ ├── nipapd.default │ ├── nipapd.init │ ├── nipapd.install │ ├── nipapd.manpages │ ├── nipapd.postinst │ ├── nipapd.postrm │ ├── nipapd.templates │ ├── py3dist-overrides │ ├── rules │ └── source │ │ ├── format │ │ └── options ├── entrypoint.sh ├── nipap-passwd.man.rst ├── nipap.conf.dist ├── nipap │ ├── __init__.py │ ├── authlib.py │ ├── backend.py │ ├── daemon.py │ ├── db_schema.py │ ├── errors.py │ ├── nipap_passwd.py │ ├── nipapconfig.py │ ├── nipapd.py │ ├── rest.py │ ├── smart_parsing.py │ ├── tracing.py │ └── xmlrpc.py ├── nipapd.man.rst ├── pyproject.toml ├── setup.py ├── sql │ ├── Makefile │ ├── clean.plsql │ ├── functions.plsql │ ├── ip_net.plsql │ ├── triggers.plsql │ ├── upgrade-1-2.plsql │ ├── upgrade-2-3.plsql │ ├── upgrade-3-4.plsql │ ├── upgrade-4-5.plsql │ ├── upgrade-5-6.plsql │ └── upgrade-6-7.plsql ├── wait-for-it.sh ├── xml-test.py └── xmlbench.py ├── nso-nipap ├── Makefile ├── README.md └── nso-nipap │ ├── load-dir │ └── .gitignore │ ├── package-meta-data.xml │ ├── private-jar │ └── .gitignore │ ├── shared-jar │ ├── commons-logging-1.1.jar │ ├── ws-commons-util-1.0.2.jar │ ├── xmlrpc-client-3.1.3.jar │ └── xmlrpc-common-3.1.3.jar │ └── src │ ├── Makefile │ ├── java │ ├── build.xml │ └── src │ │ └── net │ │ └── spritelink │ │ └── nsonipap │ │ ├── ConfigCdbSub.java │ │ ├── namespaces │ │ └── .gitignore │ │ └── nsoNipap.java │ └── yang │ └── nipap.yang ├── ojnipap ├── Makefile ├── README.rst ├── lib │ └── .gitignore └── ojnipap │ ├── API.java │ ├── Helpers.java │ ├── OAddPrefixOptions.java │ ├── OConnection.java │ ├── OPool.java │ ├── OPrefix.java │ ├── OSearchOptions.java │ └── OVRF.java ├── pynipap ├── MANIFEST.in ├── Makefile ├── README.rst ├── debian │ ├── changelog │ ├── control │ ├── copyright │ ├── rules │ └── source │ │ ├── format │ │ └── options ├── pynipap │ ├── __init__.py │ ├── pynipap.py │ └── tracing.py ├── pyproject.toml └── setup.py ├── tests ├── nipapbase.py ├── nipaptest.py ├── performance │ ├── Makefile │ ├── README.rst │ ├── find-free-prefix │ │ ├── Makefile │ │ └── README.rst │ ├── index.html │ ├── insert │ │ ├── Makefile │ │ ├── README.rst │ │ ├── data.insert-4610-24s │ │ ├── data.insert-after-ip4r │ │ ├── data.insert-start │ │ ├── index.html │ │ ├── insert.m │ │ ├── plot-after-4610-24s.png │ │ ├── plot-before-and-after.png │ │ └── plot-before.png │ └── speedtest.py ├── test_cli.py ├── test_nipap_ro.py ├── test_rest.py ├── test_xmlrpc.py ├── upgrade-after.py └── upgrade-before.py ├── utilities ├── Makefile ├── boilerplate.py ├── bulk-string-replace.py ├── convert.py ├── export-csv.py ├── export-isc-dhcp.template ├── export-template.py ├── infoblox-import.py ├── install-ip4r.sh ├── ipplan-import.py ├── news2dch.py ├── remove-all.py ├── remove_expired.py └── text-import.py └── whoisd ├── MANIFEST.in ├── Makefile ├── README.rst ├── debian ├── changelog ├── config ├── control ├── copyright ├── default ├── init ├── install ├── nipap-whoisd.manpages ├── postinst ├── rules ├── source │ ├── format │ └── options └── templates ├── nipap-whoisd ├── nipap-whoisd.man.rst ├── nipap_whoisd.py ├── pyproject.toml ├── setup.py └── whoisd.conf.dist /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore files we don't want to track. 2 | *.sw[po] 3 | *.pyc 4 | *.class 5 | *.tar.gz 6 | *.deb 7 | docs/sphinx/_build/ 8 | nipap-www/nipap_www.egg-info 9 | nipap/nipap.egg-info 10 | -------------------------------------------------------------------------------- /.hadolint.yaml: -------------------------------------------------------------------------------- 1 | failure-threshold: warning 2 | override: 3 | info: 4 | - DL3003 5 | - DL3008 6 | - DL4000 7 | -------------------------------------------------------------------------------- /.hound.yml: -------------------------------------------------------------------------------- 1 | python: 2 | enabled: true 3 | -------------------------------------------------------------------------------- /Dockerfile.nipapd: -------------------------------------------------------------------------------- 1 | # This file describes a docker image for running nipapd in docker 2 | # 3 | # Build the docker image: 4 | # docker build -t nipapd -f Dockerfile.nipapd . 5 | # 6 | # Run by linking to the container running postgres. -i -t is for interactive, 7 | # use -d if you wish to run the container in the background: 8 | # docker run -i -t --link nipap-db --name nipapd nipapd 9 | # 10 | # Most configuration variables are provided via environment variables. 11 | # LISTEN_ADDRESS address on which nipapd should listen [0.0.0.0] 12 | # LISTEN_PORT port on which nipapd should listen [1337] 13 | # SYSLOG true / false enable syslog? [false] 14 | # DB_HOST host where database is running 15 | # DB_PORT port of database [5432] 16 | # DB_NAME name of database 17 | # DB_USERNAME username to authenticate to database 18 | # DB_PASSWORD password to authenticate to database 19 | # DB_SSLMODE require ssl? [disable] 20 | # NIPAP_USERNAME name of account to create 21 | # NIPAP_PASSWORD password of account to create 22 | # 23 | # Some values have a default, indicated in square brackets, the rest you need 24 | # to fill in. If you are linking to a container running postgres, just enter 25 | # the name of the container as DB_HOST and use the credentials with which you 26 | # started that container. 27 | # 28 | # NIPAP_USERNAME & NIPAP_PASSWORD is used to create a new account in the local 29 | # auth database of nipapd so that you can later authenticate towards nipapd. It 30 | # is only possible to add a single account. If you wish to add more accounts 31 | # you should administrate the database outside and share it with the container 32 | # via a volume. 33 | # 34 | 35 | FROM ubuntu:noble 36 | MAINTAINER Kristian Larsson 37 | 38 | ENV DEBIAN_FRONTEND=noninteractive 39 | 40 | # apt update, upgrade & install packages 41 | RUN apt-get update -qy && apt-get upgrade -qy \ 42 | && apt-get install --no-install-recommends -qy build-essential \ 43 | libpq-dev \ 44 | libldap-dev \ 45 | libsasl2-dev \ 46 | libsqlite3-dev \ 47 | postgresql-client \ 48 | python3 \ 49 | python3-dev \ 50 | python3-pip \ 51 | software-properties-common \ 52 | && apt-get clean \ 53 | && rm -rf /var/lib/apt/lists/* 54 | 55 | # Install any additional CA certs from ca_certs folder required by corp proxies etc 56 | RUN mkdir /ca_certs 57 | COPY ca_certs/ /ca_certs/ 58 | RUN mkdir -p /usr/local/share/ca-certificates \ 59 | && cp /ca_certs/*.crt /usr/local/share/ca-certificates/ || true \ 60 | && rm -rf /ca_certs \ 61 | && update-ca-certificates 62 | RUN pip3 config set global.cert /etc/ssl/certs/ca-certificates.crt 63 | ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt 64 | 65 | 66 | COPY nipap /nipap 67 | WORKDIR /nipap 68 | RUN pip3 --no-input install --break-system-packages --no-cache-dir envtpl==0.7.2 \ 69 | && pip3 --no-input install -I --break-system-packages --no-cache-dir . 70 | 71 | EXPOSE 1337 72 | ENV LISTEN_ADDRESS=0.0.0.0 LISTEN_PORT=1337 SYSLOG=false DB_PORT=5432 DB_SSLMODE=disable DB_NAME=nipap 73 | 74 | ENTRYPOINT ["/nipap/entrypoint.sh"] 75 | -------------------------------------------------------------------------------- /Dockerfile.www: -------------------------------------------------------------------------------- 1 | # This file describes a docker image for running nipap-www in docker 2 | # 3 | # Build the docker image: 4 | # docker build -t nipap-www -f Dockerfile.www . 5 | # 6 | # Run by linking to the container running nipapd. -i -t is for interactive, 7 | # use -d if you wish to run the container in the background: 8 | # docker run -i -t --link nipapd --name nipap-www nipap-www 9 | # 10 | # Most configuration variables are provided via environment variables. 11 | # NIPAPD_USERNAME username to authenticate to nipapd 12 | # NIPAPD_PASSWORD password to authenticate to nipapd 13 | # NIPAPD_HOST host where nipapd is running [nipapd] 14 | # NIPAPD_PORT port of nipapd [1337] 15 | # WWW_USERNAME web UI username [guest] 16 | # WWW_PASSWORD web UI password [guest] 17 | # 18 | # Some variables have a default, indicated in square brackets, the rest you need 19 | # to fill in. If you are linking to a container running nipapd, just enter the 20 | # name of the container as NIPAPD_HOST. 21 | # 22 | # WWW_USERNAME & WWW_PASSWORD is used to create a new account in the local auth 23 | # database so that you can later login to the web interface. 24 | # 25 | 26 | FROM ubuntu:noble 27 | 28 | MAINTAINER Lukas Garberg 29 | 30 | ENV DEBIAN_FRONTEND=noninteractive 31 | 32 | ENV NIPAPD_HOST=nipapd NIPAPD_PORT=1337 WWW_USERNAME=guest WWW_PASSWORD=guest 33 | 34 | # apt update, upgrade & install packages 35 | RUN apt-get update -qy && apt-get upgrade -qy \ 36 | && apt-get install --no-install-recommends -qy apache2 \ 37 | build-essential \ 38 | libapache2-mod-wsgi-py3 \ 39 | libpq-dev \ 40 | libldap-dev \ 41 | libsasl2-dev \ 42 | libsqlite3-dev \ 43 | postgresql-client \ 44 | python3 \ 45 | python3-all \ 46 | python3-pip \ 47 | python3-dev \ 48 | && pip3 --no-input install --break-system-packages --no-cache-dir envtpl==0.7.2 \ 49 | && apt-get clean \ 50 | && rm -rf /var/lib/apt/lists/* 51 | 52 | # Install any additional CA certs from ca_certs folder required by corp proxies etc 53 | RUN mkdir /ca_certs 54 | COPY ca_certs/ /ca_certs/ 55 | RUN mkdir -p /usr/local/share/ca-certificates \ 56 | && cp /ca_certs/*.crt /usr/local/share/ca-certificates/ || true \ 57 | && rm -rf /ca_certs \ 58 | && update-ca-certificates 59 | RUN pip3 config set global.cert /etc/ssl/certs/ca-certificates.crt 60 | ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt 61 | 62 | # Install pynipap, nipap and nipap-www 63 | COPY pynipap /pynipap 64 | COPY nipap /nipap 65 | COPY nipap-www /nipap-www 66 | RUN cd /pynipap && pip3 --no-input install --break-system-packages --no-cache-dir . && \ 67 | cd /nipap && pip3 --no-input install --break-system-packages --no-cache-dir . && \ 68 | cd /nipap-www && pip3 --no-input install --break-system-packages --no-cache-dir . && \ 69 | mkdir -p /etc/nipap/www/ && cp nipap-www.wsgi /etc/nipap/www/ && \ 70 | cd .. 71 | 72 | EXPOSE 80 73 | VOLUME [ "/var/log/apache2" ] 74 | 75 | ENTRYPOINT [ "/nipap-www/entrypoint.sh" ] 76 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation of NIPAP 2 | ===================== 3 | 4 | Please see docs/INSTALL.rst for installation and upgrading instructions of 5 | NIPAP. 6 | 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011-2014 Kristian Larsson, Lukas Garberg 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2011/04/18 17:14:00 lukagarb Exp $ 2 | # 3 | 4 | # for use lates, when we have cleaned up a bit! 5 | #SUBPROJ=`find $(CURDIR)/* -maxdepth 0 -type d` 6 | SUBPROJ=nipap pynipap nipap-www nipap-cli whoisd 7 | APTDIR=apt 8 | CURBRANCH=$(shell git branch --no-color 2> /dev/null | awk '/\\*/ { printf("%s", $$2); }') 9 | 10 | all: 11 | @echo "make source - Create source package" 12 | @echo "make install - Install on local system" 13 | @echo "make buildrpm - Generate a rpm package" 14 | @echo "make builddeb - Generate a deb package" 15 | @echo "make clean - Get rid of scratch and byte files" 16 | @echo "make bumpversion - Bump version to latest in NEWS file" 17 | @echo "make debrepo-stable - Copy packages from testing repo into stable repo" 18 | @echo "make debrepo-testing - Create or update the testing repo" 19 | 20 | source: 21 | for PROJ in $(SUBPROJ); do \ 22 | cd $$PROJ; make source; cd ..; \ 23 | done 24 | 25 | install: 26 | for PROJ in $(SUBPROJ); do \ 27 | cd $$PROJ; make install; cd ..; \ 28 | done 29 | 30 | buildrpm: 31 | for PROJ in $(SUBPROJ); do \ 32 | cd $$PROJ; make buildrpm; cd ..; \ 33 | done 34 | 35 | builddeb: 36 | for PROJ in $(SUBPROJ); do \ 37 | cd $$PROJ; make builddeb; cd ..; \ 38 | done 39 | 40 | ifeq ($(CURBRANCH), $(shell echo -n 'gh-pages')) 41 | debrepo-stable: debrepo-stable-run 42 | else 43 | debrepo-stable: 44 | @echo "Please switch to branch: gh-pages" 45 | @echo "If you want to force the building of a debrepo, run 'make debrepo-run'" 46 | endif 47 | 48 | ifeq ($(CURBRANCH), $(shell echo -n 'gh-pages')) 49 | debrepo-testing: debrepo-testing-run 50 | else 51 | debrepo-testing: 52 | @echo "Please switch to branch: gh-pages" 53 | @echo "If you want to force the building of a debrepo, run 'make debrepo-testing-run'" 54 | endif 55 | 56 | debrepo-stable-run: 57 | cd repos/apt; \ 58 | for PACKAGE in `reprepro list testing | awk '{ print $$2 }' | sort | uniq`; do \ 59 | reprepro copy stable testing $$PACKAGE; \ 60 | done; \ 61 | cd ../.. 62 | 63 | debrepo-testing-run: 64 | for CHANGEFILE in `ls *.changes`; do \ 65 | cd repos/apt; \ 66 | reprepro --ignore=wrongdistribution -Vb . include stable ../../$$CHANGEFILE; \ 67 | cd ../.. ; \ 68 | done 69 | 70 | clean: 71 | rm -f *.deb 72 | rm -f *.tar.gz 73 | rm -f *.tar.xz 74 | rm -f *.build 75 | rm -f *.buildinfo 76 | rm -f *.changes 77 | rm -f *.dsc 78 | rm -f *.diff.gz 79 | rm -rf repos/apt/db repos/apt/dist repos/apt/pool 80 | for PROJ in $(SUBPROJ); do \ 81 | cd $$PROJ; make clean; cd ..; \ 82 | done 83 | 84 | bumpversion: 85 | for PROJ in $(SUBPROJ); do \ 86 | cd $$PROJ; make bumpversion; cd ..; \ 87 | done 88 | -------------------------------------------------------------------------------- /ca_certs/README.rst: -------------------------------------------------------------------------------- 1 | Custom CA Certs for docker containers 2 | ===================================== 3 | If you need to include specific CA certs which you must trust, place them here 4 | in PEM format, named \*.crt. 5 | 6 | This may be required if you need to build the container from inside a network 7 | which uses a proxy or similar, or other dependencies towards internal services 8 | are included in your containers. -------------------------------------------------------------------------------- /docs/INSTALL.rst: -------------------------------------------------------------------------------- 1 | Installation of NIPAP 2 | ===================== 3 | NIPAP is officially supported on Debian and Debian derivatives. This includes 4 | pre-built packages, an automated installation (using Debians post-installation 5 | script) and above all, that it is tested. 6 | 7 | 8 | Installation 9 | ------------ 10 | If you are running a Debian system or a Debian derivative, see 11 | `installing on Debian `_ for instructions. 12 | 13 | NIPAP should be able to run on any Unix-like operating system but you will need 14 | to install dependencies and NIPAP manually. See `installing on Unix systems 15 | `_ for instructions. 16 | 17 | 18 | Upgrading 19 | --------- 20 | For upgrading on Debian / Ubuntu make sure you use:: 21 | 22 | apt-get dist-upgrade 23 | 24 | The 'upgrade' command will not install any new dependencies and since it's 25 | fairly common that we introduce new dependencies in NIPAP it's prudent to 26 | always use dist-upgrade. 27 | 28 | 29 | Configuration 30 | ------------- 31 | Once you have NIPAP installed on your machine, read `nipap configuration 32 | `_ for a configuration guide of the NIPAP backend (nipapd). 33 | 34 | Check out `CLI configuration `_ and / or `configuration of 35 | nipap-www `_ which covers the necessary configuration for 36 | setting up the NIPAP web UI. 37 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | 2 | DOCS=INSTALL.rst config-cli.rst config-nipapd.rst config-www.rst install-debian.rst install-unix.rst 3 | 4 | all: 5 | for DOC in $(DOCS); do \ 6 | OUT=`echo $$DOC | sed -e 's/.rst$$/.html/'`; \ 7 | rst2html $$DOC | sed -ne '//p' | \ 8 | sed -e 's//---\n---\n{% include header.html %}/' | \ 9 | sed -e 's/<\/body>/{% include footer.html %}/' | \ 10 | sed -e 's/href="\([^"]\+\).rst"/href="\1.html"/g' > $$OUT; \ 11 | done 12 | 13 | clean: 14 | for DOC in $(DOCS); do \ 15 | OUT=`echo $$DOC | sed -e 's/.rst$$/.html/'`; \ 16 | rm $$OUT; \ 17 | done 18 | -------------------------------------------------------------------------------- /docs/README.logging: -------------------------------------------------------------------------------- 1 | Where do we log? 2 | What do we log? 3 | When do we log? 4 | -------------------------------------------------------------------------------- /docs/config-cli.rst: -------------------------------------------------------------------------------- 1 | CLI configuration 2 | ----------------- 3 | Once you have the nipap-cli package installed (or if you've installed the CLI 4 | manually), a new command, 'nipap', is available to you. It reads .nipaprc in 5 | your home directory and expects to find things like the host address of nipapd 6 | and authentication credentials. 7 | 8 | If you haven't already done so, you can create a new user so that you can 9 | authenticate against nipapd. Execute the following on the machine running 10 | nipapd to create a new user in the local authentication database:: 11 | 12 | nipap-passwd add -u *username* -p *username* -n "My CLI user" 13 | 14 | Where *username* and *password* is the username and password you wish to 15 | create. Use the same username and password to fill in your .nipaprc. Here's an 16 | example .nipaprc that will work towards localhost with the user you just 17 | created (also see nipap-cli/nipaprc for a more complete example):: 18 | 19 | [global] 20 | hostname = localhost 21 | port = 1337 22 | username = *username* 23 | password = *password* 24 | default_vrf_rt = none 25 | default_list_vrf_rt = all 26 | 27 | Naturally, if you are running the CLI and nipapd on two different machines, 28 | 'hostname' will need to be set to the machine where nipapd is running. 29 | 30 | 'default_vrf_rt' specifies the RT of the VRF used as default by 'nipap address 31 | add/modify/remove/view' commands when no other VRF RT is explicitly specified 32 | on the command line. It is also used as default VRF when expanding a pool with 33 | a new prefix for the first time. 'nona' or '-' means VRF 'Default' (RT: -) 34 | 35 | 'default_list_vrf_rt' is used by 'nipap address list' which per default will 36 | search in the following VRF RT when no VRF RT is explicitly specified on the 37 | command line. 'all' means that searches will include results from all VRFs. 38 | 39 | Let's try adding a prefix too:: 40 | 41 | nipap address add prefix 192.0.2.0/24 type assignment description "test prefix" 42 | 43 | And list everything covered by 0.0.0.0/0:: 44 | 45 | nipap address list 0/0 46 | 47 | -------------------------------------------------------------------------------- /docs/config-nipapd.rst: -------------------------------------------------------------------------------- 1 | Configuration of the NIPAP backend (nipapd) 2 | =========================================== 3 | Make sure nipapd is installed. 4 | 5 | nipapd will not be able to start until it can connect to the backend database 6 | and as postgresql does not by default listen to localhost (127.0.0.1), you will 7 | need to edit /etc/postgresql/9.1/main/postgresql.conf and uncomment the 8 | listen_address line to have it listen to localhost (or all '*'). 9 | 10 | If you installed nipapd using the Debian packages, it prompted you to 11 | automatically setup the database connection in which case you should not need 12 | to do anything further but (re)start nipapd. If you installed nipapd manually, 13 | you will need to fill in your database connection parameters in nipap.conf 14 | yourself. 15 | 16 | Once done, restart nipapd:: 17 | 18 | /etc/init.d/nipapd restart 19 | 20 | Per default, nipapd itself only listens to localhost (127.0.0.1). If you are 21 | going to run the web UI on the same machine and/or the CLI from the same 22 | machine, you do not need to change anything. If you on the other hand wish to 23 | run any of these from a second machine, you need to change the "listen" line in 24 | nipap.conf. 25 | for it to listen on all addresses, change the "listen" line in nipap.conf. 26 | -------------------------------------------------------------------------------- /docs/config-www.rst: -------------------------------------------------------------------------------- 1 | Configuration of the web UI 2 | --------------------------- 3 | Make sure the web UI is installed before proceeding with configuration of it. 4 | 5 | The web interface needs its own user account to authenticate towards the 6 | backend and it should be a *trusted* account. Create it with the following:: 7 | 8 | nipap-passwd add --username nipap-www --password s3cr3t --name "User account for the web UI" --trusted 9 | 10 | Obviously, replace "s3cr3t" with a better password and feel free to use 11 | whichever username you want, as long as you configure it accordingly. The user 12 | account for the web UI should not be used by any other user. Configure 13 | the web UI to use this account by configuring the xmlrpc_uri variable in the 14 | www section of nipap.conf:: 15 | 16 | xmlrpc_uri = http://nipap-www@local:s3cr3t@127.0.0.1:1337 17 | 18 | This configuring assumes that you did indeed name the account "nipap-www", 19 | replace "s3cr3t" with your password. "@local" instructs the backend to use the 20 | "local" authentication backend. If you are running nipapd on a different host 21 | or port, then update the "127.0.0.1:1337" part accordingly. 22 | 23 | Finally, you can add a user for yourself and once you've configured your web 24 | server to serve the NIPAP web UI you should be able to login with this user:: 25 | 26 | nipap-passwd add --username myuser --password mypassword --name "my user" 27 | 28 | 29 | Serving the web UI 30 | ------------------ 31 | The NIPAP web UI is built on the web framework Flask can be served by any 32 | WGSI-capable web server such as Apache httpd with mod_wsgi. For quick tests and 33 | development Flask's own web server is handy. 34 | 35 | Flask 36 | ====== 37 | Using Flask is the easiest way to get the NIPAP web UI up and running, but 38 | it's not really suitable for production deployment. To serve the NIPAP web UI 39 | from the built-in web server, run the following:: 40 | 41 | export FLASK_APP=nipapwww 42 | export FLASK_ENV=development 43 | flask run 44 | 45 | Using the default configuration, the web UI should now be reachable on port 46 | 5000. By default, the NIPAP web UI will look for nipap.conf in /etc/nipap. The 47 | path can be changed setting the environment variable NIPAP_CONFIG_PATH as 48 | such:: 49 | 50 | export NIPAP_CONFIG_PATH=~/.local/etc/nipap/nipap.conf 51 | 52 | Apache httpd with mod_wsgi 53 | ========================== 54 | Begin by installing Apache httpd with mod_wsgi:: 55 | 56 | apt-get install libapache2-mod-wsgi-py3 57 | 58 | Then, add a new virtual host or configure the default one with the line:: 59 | 60 | WSGIScriptAlias / /etc/nipap/www/nipap-www.wsgi 61 | 62 | If you are using Apache 2.4 you will also need to add the lines:: 63 | 64 | 65 | Require all granted 66 | 67 | 68 | The web server needs to be able to write to its cache, alter the permissions of 69 | /var/cache/nipap-www so that the web server can write to it and preferrably 70 | also make sure no one else has access to it. For a typical Debian install of 71 | Apache httpd, the following should suffice:: 72 | 73 | chown -R www-data:www-data /var/cache/nipap-www 74 | chmod -R u=rwX /var/cache/nipap-www 75 | 76 | Now, restart Apache httpd and the NIPAP web UI should be up and running! 77 | 78 | That wraps up this getting started guide, for more information see the manual 79 | pages. 80 | -------------------------------------------------------------------------------- /docs/getting-started-development.rst: -------------------------------------------------------------------------------- 1 | Getting started with NIPAP development 2 | ====================================== 3 | Got a good idea or some spare time to kill? Help out with NIPAP development and 4 | receive fame! 5 | 6 | This guide will try to help you setup an enviroment for further developing 7 | NIPAP into what you want it to become or just help fix identified bugs. The sky 8 | is the limit. 9 | 10 | Start a local nipapd 11 | -------------------- 12 | You really need the nipapd backend to do any form of development since it's 13 | such a crucial part of the NIPAP system. You'll find the nipapd program in 14 | $NIPAP/nipap. nipapd forks into the background by default as well as writing a 15 | PID file in /var/run. Since development usually doesn't happen as root and most 16 | users don't have access to write files in /var/run, it is recommended to 17 | disable writing a pid file by using the option --no-pid-file. It also helps 18 | avoiding collisions with another running (production?) nipapd, just as changing 19 | the TCP port to listen with --port to does. Last but not least, if you want 20 | some debugging output, it is pretty useful to let nipapd stay in the foreground 21 | and set the log level to debug:: 22 | 23 | cd nipap 24 | ./nipapd -d -f --no-pid-file --port 1234 25 | 26 | 27 | Using Flask to serve the web UI 28 | -------------------------------- 29 | In a production environment the NIPAP web UI is typically served via Apache. 30 | For a development environment it is a lot quicker and easier to use Flask's 31 | built-in web server. 32 | 33 | Starting it is no more difficult than running:: 34 | 35 | cd nipap-www 36 | export FLASK_APP=nipapwww 37 | export FLASK_ENV=development 38 | flask run 39 | 40 | It does require that you have the required dependencies installed and reachable 41 | for paster to work properly. The easiest way of accomplishing this, especially 42 | if you intend on doing development in pynipap (the python client library), is 43 | to use virtualenv. Set up a new virtualenv by doing:: 44 | 45 | virtualenv --system-site-packages venv 46 | 47 | Activate it:: 48 | 49 | . venv/bin/activate 50 | 51 | Install pynipap in your virtualenv:: 52 | 53 | cd ../pynipap 54 | python setup.py install 55 | 56 | And go back and run Flask:: 57 | 58 | cd ../nipap-www/ 59 | export FLASK_APP=nipapwww 60 | export FLASK_ENV=development 61 | flask run 62 | 63 | If you just run paster you will not utilize the python installed in the 64 | virtualenv and will thus not have access to the pynipap installed in the 65 | virtualenv. 66 | 67 | Reach Ballmer peak and code moar 68 | ---------------------------------- 69 | As has been `empirically proven `_, a moderate BAC will 70 | vastly improve programming ability. The developers of NIPAP recommend Belgian 71 | Trappiste or a nice stout or an IPA or a whisky or a light lager or really, 72 | anything you like. It's important you like it. Now code moar! 73 | 74 | .. image:: mustcodemoar.jpg 75 | :alt: Must code MOAR! 76 | -------------------------------------------------------------------------------- /docs/sphinx/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | 15 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " pickle to make pickle files" 22 | @echo " json to make JSON files" 23 | @echo " htmlhelp to make HTML files and a HTML help project" 24 | @echo " qthelp to make HTML files and a qthelp project" 25 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 26 | @echo " changes to make an overview of all changed/added/deprecated items" 27 | @echo " linkcheck to check all external links for integrity" 28 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 29 | 30 | clean: 31 | -rm -rf $(BUILDDIR)/* 32 | 33 | html: 34 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 35 | @echo 36 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 37 | for f in `ls $(BUILDDIR)/html/*.html`; do\ 38 | sed -e 's/_static/static/' $$f > tmp;\ 39 | mv tmp $$f;\ 40 | done 41 | 42 | if [ -d $(BUILDDIR)/html/_static ]; then \ 43 | mv $(BUILDDIR)/html/_static $(BUILDDIR)/html/static;\ 44 | fi 45 | 46 | dirhtml: 47 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 48 | @echo 49 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 50 | 51 | pickle: 52 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 53 | @echo 54 | @echo "Build finished; now you can process the pickle files." 55 | 56 | json: 57 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 58 | @echo 59 | @echo "Build finished; now you can process the JSON files." 60 | 61 | htmlhelp: 62 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 63 | @echo 64 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 65 | ".hhp project file in $(BUILDDIR)/htmlhelp." 66 | 67 | qthelp: 68 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 69 | @echo 70 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 71 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 72 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/NIPAP.qhcp" 73 | @echo "To view the help file:" 74 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/NIPAP.qhc" 75 | 76 | latex: 77 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 78 | @echo 79 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 80 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 81 | "run these through (pdf)latex." 82 | 83 | changes: 84 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 85 | @echo 86 | @echo "The overview file is in $(BUILDDIR)/changes." 87 | 88 | linkcheck: 89 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 90 | @echo 91 | @echo "Link check complete; look for any errors in the above output " \ 92 | "or in $(BUILDDIR)/linkcheck/output.txt." 93 | 94 | doctest: 95 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 96 | @echo "Testing of doctests in the sources finished, look at the " \ 97 | "results in $(BUILDDIR)/doctest/output.txt." 98 | -------------------------------------------------------------------------------- /docs/sphinx/README: -------------------------------------------------------------------------------- 1 | NIPAP documentation 2 | ------------------- 3 | 4 | The main NIPAP documentation is generated using the Sphinx 5 | (http://sphinx.pocoo.org) document generator. To build everything, make sure 6 | you have sphinx installed and run: 7 | 8 | make html 9 | 10 | in the current directory to generate the HTML documentation. The generated 11 | files are then placed in the _build/html/ directory. 12 | -------------------------------------------------------------------------------- /docs/sphinx/authlib.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: nipap.authlib 2 | :members: 3 | -------------------------------------------------------------------------------- /docs/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | .. NIPAP documentation master file, created by 2 | sphinx-quickstart on Wed Jun 22 11:04:45 2011. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Neat IP-Address Planner 7 | ======================= 8 | 9 | The majority of this documentation is generated from the Nipap Python module 10 | where most of the server side logic is placed. A thin XML-RPC layer is wrapped 11 | around the Nipap class to expose its functions over an XML-RPC interface as well 12 | as translating internal Exceptions into XML-RPC errors codes. It is feasible to 13 | implement other wrapper layers should one need a different interface, though 14 | the XML-RPC interface should serve most well. 15 | 16 | Given that the documentation is automatically generated from this internal Nipap 17 | class, there is some irrelevant information regarding class structures - just 18 | ignore that! :) 19 | 20 | Happy hacking! 21 | 22 | Contents: 23 | 24 | .. toctree:: 25 | :maxdepth: 2 26 | 27 | design 28 | nipap 29 | pynipap 30 | xmlrpc 31 | authlib 32 | release-handling 33 | 34 | 35 | Indices and tables 36 | ================== 37 | 38 | * :ref:`genindex` 39 | * :ref:`modindex` 40 | * :ref:`search` 41 | 42 | -------------------------------------------------------------------------------- /docs/sphinx/nipap.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: nipap.backend 2 | :members: 3 | -------------------------------------------------------------------------------- /docs/sphinx/pynipap.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: pynipap 2 | :members: 3 | -------------------------------------------------------------------------------- /docs/sphinx/release-handling.rst: -------------------------------------------------------------------------------- 1 | ../release-handling.rst -------------------------------------------------------------------------------- /docs/sphinx/requirements.txt: -------------------------------------------------------------------------------- 1 | parsedatetime 2 | python-dateutil 3 | Flask-XML-RPC 4 | Flask-Compress 5 | -------------------------------------------------------------------------------- /docs/sphinx/xmlrpc.rst: -------------------------------------------------------------------------------- 1 | .. automodule:: nipap.xmlrpc 2 | :members: 3 | -------------------------------------------------------------------------------- /jnipap/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | jnipap.jar 3 | .gradle 4 | -------------------------------------------------------------------------------- /jnipap/Makefile: -------------------------------------------------------------------------------- 1 | default: jar 2 | 3 | jar: 4 | gradlew jar 5 | cp build/libs/jnipap.jar . 6 | 7 | test: 8 | gradle test 9 | 10 | clean: 11 | gradle clean 12 | -------------------------------------------------------------------------------- /jnipap/README.rst: -------------------------------------------------------------------------------- 1 | JNIPAP - a Java NIPAP client library 2 | ==================================== 3 | JNIPAP is a Java client library to communicate with the NIPAP server via 4 | XML-RPC. 5 | 6 | Build instructions 7 | ------------------ 8 | JNIPAP depends on parts of the Apache Web Services framework. All dependencies 9 | are shipped with the NIPAP repository, so as long as you have gradle in your 10 | path you should be able to build the JNIPAP .jar with: 11 | 12 | ``make jar`` 13 | 14 | To run tests, do: 15 | 16 | ``make test`` 17 | -------------------------------------------------------------------------------- /jnipap/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'barisa' at '10/18/16 12:36 AM' with Gradle 3.1 4 | * 5 | * This generated file contains a sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at https://docs.gradle.org/3.1/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | // Apply the java plugin to add support for Java 11 | apply plugin: 'java' 12 | 13 | // In this section you declare where to find the dependencies of your project 14 | repositories { 15 | // Use 'jcenter' for resolving your dependencies. 16 | // You can declare any Maven/Ivy/file repository here. 17 | mavenCentral() 18 | } 19 | 20 | // In this section you declare the dependencies for your production and test code 21 | dependencies { 22 | // The production code uses the SLF4J logging API at compile time 23 | compile 'org.slf4j:slf4j-api:1.7.21' 24 | 25 | compile group: 'commons-logging', name: 'commons-logging', version: '1.1' 26 | compile group: 'org.apache.ws.commons', name: 'ws-commons-util', version: '1.0.1' 27 | compile group: 'org.apache.xmlrpc', name: 'xmlrpc-client', version: '3.1.3' 28 | compile group: 'org.apache.xmlrpc', name: 'xmlrpc-common', version: '3.1.3' 29 | 30 | // Declare the dependency for your favourite test framework you want to use in your tests. 31 | // TestNG is also supported by the Gradle Test task. Just change the 32 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 33 | // 'test.useTestNG()' to your build script. 34 | testCompile 'junit:junit:4.12' 35 | } 36 | 37 | tasks.withType(JavaCompile) { 38 | options.compilerArgs << "-Xlint" 39 | } 40 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/AddPrefixOptions.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | import java.util.HashMap; 4 | 5 | /** 6 | * A class which contains options to the API function add_prefix. 7 | * 8 | * NOTE: The AddPrefixOptions hash is changed by some API calls, so please do 9 | * not reuse! 10 | */ 11 | public class AddPrefixOptions extends HashMap { 12 | 13 | // version ID for serialization 14 | private static final long serialVersionUID = 0L; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/AuthFailedException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Thrown when authentication against NIPAP service fails. 5 | */ 6 | public class AuthFailedException extends JnipapException { 7 | 8 | // version ID for serialization 9 | private static final long serialVersionUID = 0L; 10 | 11 | public AuthFailedException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public AuthFailedException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/ConnectionException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Connection related errors 5 | * 6 | * Timeouts, ... 7 | */ 8 | public class ConnectionException extends JnipapException { 9 | 10 | // version ID for serialization 11 | private static final long serialVersionUID = 0L; 12 | 13 | public ConnectionException(String msg) { 14 | super(msg); 15 | } 16 | 17 | public ConnectionException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/DuplicateException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * The requested addition/change violates unique constraints 5 | * 6 | * For example, when creating a VRF which already exists. 7 | */ 8 | public class DuplicateException extends JnipapException { 9 | 10 | // version ID for serialization 11 | private static final long serialVersionUID = 0L; 12 | 13 | public DuplicateException(String msg) { 14 | super(msg); 15 | } 16 | 17 | public DuplicateException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/InputException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * General input error exception 5 | */ 6 | class InputException extends JnipapException { 7 | 8 | // version ID for serialization 9 | private static final long serialVersionUID = 0L; 10 | 11 | public InputException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public InputException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/InvalidParameterException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Thrown when invalid parameters were received 5 | */ 6 | public class InvalidParameterException extends JnipapException { 7 | 8 | // version ID for serialization 9 | private static final long serialVersionUID = 0L; 10 | 11 | public InvalidParameterException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public InvalidParameterException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/Jnipap.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | import java.util.HashMap; 4 | 5 | import jnipap.Connection; 6 | 7 | /** 8 | * Base class for all NIPAP object classes (VRF, Pool, Prefix). 9 | * 10 | * Maintains an XML-RPC connection to the NIPAP daemon. 11 | * 12 | * @author Lukas Garberg 13 | */ 14 | abstract public class Jnipap { 15 | 16 | public Integer id; 17 | 18 | protected Connection conn; 19 | 20 | /** 21 | * Save the object to NIPAP 22 | */ 23 | abstract public void save(Connection auth) throws JnipapException; 24 | 25 | /** 26 | * Remove object from NIPAP 27 | */ 28 | abstract public void remove(Connection auth) throws JnipapException; 29 | 30 | /** 31 | * Compute hash of NIPAP object 32 | */ 33 | public int hashCode() { 34 | 35 | int hash = 1; 36 | hash = hash * 31 + (id == null ? 0 : id.hashCode()); 37 | 38 | return hash; 39 | 40 | } 41 | 42 | /** 43 | * Compute equality 44 | */ 45 | public boolean equals(Object other) { 46 | 47 | if (other == this) return true; 48 | if (other == null) return false; 49 | if (getClass() != other.getClass()) return false; 50 | Jnipap jnipap = (Jnipap)other; 51 | 52 | return (id == jnipap.id || id.equals(jnipap.id)); 53 | 54 | } 55 | 56 | /** 57 | * Add value to hash map unless null. 58 | * 59 | * Helper function which adds an element to a HashMap unless the value is 60 | * null. 61 | */ 62 | protected void putUnlessNull(HashMap hash, Object key, Object value) { 63 | 64 | if (value != null) { 65 | hash.put(key, value); 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/JnipapException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Top-level Jnipap exception 5 | */ 6 | public class JnipapException extends Exception { 7 | 8 | // version ID for serialization 9 | private static final long serialVersionUID = 0L; 10 | 11 | public JnipapException(String msg) { 12 | super(msg); 13 | } 14 | 15 | public JnipapException(Throwable cause) { 16 | super(cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/MissingInputException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Missing input data to a remote procedure call 5 | * 6 | * This can probably be a RuntimeError instead 7 | */ 8 | public class MissingInputException extends InputException { 9 | 10 | // version ID for serialization 11 | private static final long serialVersionUID = 0L; 12 | 13 | public MissingInputException(String msg) { 14 | super(msg); 15 | } 16 | 17 | public MissingInputException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/NonExNullParser.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | import org.apache.ws.commons.util.NamespaceContextImpl; 4 | import org.apache.xmlrpc.common.TypeFactoryImpl; 5 | import org.apache.xmlrpc.common.XmlRpcController; 6 | import org.apache.xmlrpc.common.XmlRpcStreamConfig; 7 | import org.apache.xmlrpc.parser.NullParser; 8 | import org.apache.xmlrpc.parser.TypeParser; 9 | import org.apache.xmlrpc.serializer.NullSerializer; 10 | 11 | /** 12 | * Class which handles parsing of values 13 | * 14 | * As the Apache XML-RPC client implementation only accepts nil values in the 15 | * ex namespace (), this parser is implemented to make it handle nil 16 | * without the namespace. 17 | * 18 | * This is how the Twisted XML-RPC-daemon handles nil. 19 | */ 20 | public class NonExNullParser extends TypeFactoryImpl { 21 | 22 | /** 23 | * Create instance. 24 | * 25 | * @param pController 26 | */ 27 | public NonExNullParser(XmlRpcController pController) { 28 | super(pController); 29 | } 30 | 31 | public TypeParser getParser(XmlRpcStreamConfig pConfig, 32 | NamespaceContextImpl pContext, String pURI, 33 | String pLocalName) { 34 | 35 | if ("".equals(pURI) && NullSerializer.NIL_TAG.equals(pLocalName)) { 36 | return new NullParser(); 37 | } else { 38 | return super.getParser(pConfig, pContext, pURI, pLocalName); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/NonExistentException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * A non-existent object was specified 5 | * 6 | * Thrown when for example trying to get a prefix from a pool which does not 7 | * exist or using the .get()-method on an ID which does not exist. 8 | */ 9 | public class NonExistentException extends JnipapException { 10 | 11 | // version ID for serialization 12 | private static final long serialVersionUID = 0L; 13 | 14 | public NonExistentException(String msg) { 15 | super(msg); 16 | } 17 | 18 | public NonExistentException(Throwable cause) { 19 | super(cause); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /jnipap/src/main/java/jnipap/ValueException.java: -------------------------------------------------------------------------------- 1 | package jnipap; 2 | 3 | /** 4 | * Invalid value specified 5 | * Thrown for example when an integer is specified when an IP address is 6 | * expected. 7 | */ 8 | public class ValueException extends JnipapException { 9 | 10 | // version ID for serialization 11 | private static final long serialVersionUID = 0L; 12 | 13 | public ValueException(String msg) { 14 | super(msg); 15 | } 16 | 17 | public ValueException(Throwable cause) { 18 | super(cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /nipap-cli/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst MANIFEST.in 2 | prune Makefile 3 | prune debian/* 4 | -------------------------------------------------------------------------------- /nipap-cli/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2012/02/29 08:55:00 lukagarb Exp $ 2 | # 3 | 4 | PYTHON=`which python3` 5 | DESTDIR=/ 6 | BUILDIR=$(CURDIR)/debian/python-nipap-build 7 | PROJECT=nipap-cli 8 | 9 | all: 10 | # $(PYTHON) setup.py build 11 | @echo "make source - Create source package" 12 | @echo "make install - Install on local system" 13 | @echo "make buildrpm - Generate a rpm package" 14 | @echo "make builddeb - Generate a deb package" 15 | @echo "make bumpversion - Bump version to latest in ../NEWS file" 16 | @echo "make clean - Get rid of scratch and byte files" 17 | 18 | source: 19 | $(PYTHON) setup.py sdist 20 | 21 | install: 22 | $(PYTHON) setup.py install 23 | 24 | buildrpm: 25 | $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall 26 | 27 | builddeb: 28 | # build the source package in the parent directory 29 | # then rename it to project_version.orig.tar.gz 30 | $(PYTHON) -m build --sdist --outdir=../ 31 | rename -f 's/nipap_cli-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* 32 | # build the package 33 | debuild -us -uc 34 | 35 | distclean: 36 | realclean: 37 | test: 38 | check: 39 | 40 | upload: 41 | $(PYTHON) setup.py sdist upload 42 | 43 | clean: 44 | $(PYTHON) setup.py clean 45 | rm -rf .pybuild/ MANIFEST dist/ debian/tmp debian/$(PROJECT) debian/files \ 46 | .pc/ debian/$(PROJECT).debhelper.log debian/$(PROJECT).postinst.debhelper \ 47 | debian/$(PROJECT).prerm.debhelper debian/$(PROJECT).substvars nipap.1 \ 48 | debian/.debhelper debian/debhelper-build-stamp nipap_cli.egg-info 49 | find . -name '*.pyc' -delete 50 | 51 | VER := $(shell head -n1 ../NEWS | awk '{print $$2}') 52 | bumpversion: 53 | # replace version number in nipap_cli/__init__.py 54 | sed -i 's/\(__version__\s*= \)"[^"]\+"/\1"$(VER)"/' nipap_cli/__init__.py 55 | # update debian/changelog 56 | ../utilities/news2dch.py ../NEWS debian/changelog 57 | -------------------------------------------------------------------------------- /nipap-cli/README.rst: -------------------------------------------------------------------------------- 1 | NIPAP shell command 2 | =================== 3 | NIPAP is a system built for managing large amounts of IP addresses built as an 4 | XML-RPC service. This package contains a shell command which accesses this 5 | service. 6 | -------------------------------------------------------------------------------- /nipap-cli/bash_complete: -------------------------------------------------------------------------------- 1 | _nipap() 2 | { 3 | local words 4 | local cur 5 | # set IFS to newline to handle tab completion for entries containing a space 6 | local IFS=$'\n' 7 | 8 | COMPREPLY=() 9 | _get_comp_words_by_ref -n : words cur 10 | 11 | if [[ ${#cur} -eq 0 ]]; then 12 | COMPREPLY=( $( helper-nipap ${words[@]} '' ) ) 13 | else 14 | COMPREPLY=( $( helper-nipap ${words[@]} ) ) 15 | fi 16 | 17 | __ltrim_colon_completions "$cur" 18 | 19 | return; 20 | 21 | } 22 | # -o filenames helps us correctly escape spaces and similar in the COMPREPLY 23 | complete -o filenames -F _nipap nipap 24 | -------------------------------------------------------------------------------- /nipap-cli/debian/control: -------------------------------------------------------------------------------- 1 | Source: nipap-cli 2 | Maintainer: Lukas Garberg 3 | Section: python 4 | Priority: optional 5 | Build-Depends: debhelper-compat (= 13), 6 | dh-python, 7 | dh-exec, 8 | python3-all, 9 | python3-setuptools, 10 | bash-completion 11 | Standards-Version: 4.6.1 12 | 13 | Package: nipap-cli 14 | Architecture: all 15 | Depends: ${misc:Depends}, ${python3:Depends} 16 | Description: Neat IP Address Planner 17 | The Neat IP Address Planner, NIPAP, is a system built for efficiently managing 18 | large amounts of IP addresses. This is the shell command. 19 | -------------------------------------------------------------------------------- /nipap-cli/debian/copyright: -------------------------------------------------------------------------------- 1 | Package created by Lukas Garberg (lukagarb) 2 | on Wed, 29 Feb 2012 08:55:00 +0200. 3 | 4 | Upstream Author: 5 | 6 | Kristian Larsson (kll) 7 | Lukas Garberg (lukagarb) 8 | 9 | Files: * 10 | Copyright: 11 | 2011, Tele2 AB 12 | License: MIT 13 | 14 | License: MIT 15 | Copyright (C) 2011 by Kristian Larsson, Lukas Garberg 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /nipap-cli/debian/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/dh-exec 2 | nipaprc => /etc/.nipaprc 3 | -------------------------------------------------------------------------------- /nipap-cli/debian/nipap-cli.bash-completion: -------------------------------------------------------------------------------- 1 | ../bash_complete -------------------------------------------------------------------------------- /nipap-cli/debian/nipap.manpages: -------------------------------------------------------------------------------- 1 | nipap.1 2 | -------------------------------------------------------------------------------- /nipap-cli/debian/postinst: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | install -D /usr/share/doc/nipap-cli/bash_complete /etc/bash_completion.d/nipap 6 | 7 | #DEBHELPER# 8 | -------------------------------------------------------------------------------- /nipap-cli/debian/postrm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | rm -f /etc/bash_completion.d/nipap 6 | 7 | #DEBHELPER# 8 | -------------------------------------------------------------------------------- /nipap-cli/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | #export DH_VERBOSE=1 4 | #export PYBUILD_NAME=nipap-cli 5 | #export PYBUILD_INSTALL_ARGS=--install-lib usr/lib/python3/dist-packages/ 6 | 7 | %: 8 | dh $@ --with python3 --buildsystem=pybuild --with bash-completion 9 | -------------------------------------------------------------------------------- /nipap-cli/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /nipap-cli/debian/source/options: -------------------------------------------------------------------------------- 1 | # Don't store "changes" made to Makefile 2 | extend-diff-ignore = "(^|/)(Makefile|cli-test.py|MANIFEST|nipap.man.rst|requirements.txt)$" 3 | -------------------------------------------------------------------------------- /nipap-cli/helper-nipap: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | 3 | """ CLI command completion helper 4 | 5 | nipap_helper.py is used to provide tab completion capabilities of nipap 6 | commands to for example bash. 7 | """ 8 | 9 | import configparser 10 | import os 11 | import shlex 12 | import sys 13 | from nipap_cli.command import Command, InvalidCommand 14 | from nipap_cli import nipap_cli 15 | from pynipap import NipapError 16 | 17 | 18 | __author__ = "Kristian Larsson, Lukas Garberg" 19 | __author_email__ = "kll@tele2.net, lukas@spritelink.net" 20 | __license__ = "MIT" 21 | __status__ = "Development" 22 | __url__ = "http://SpriteLink.github.io/NIPAP/" 23 | 24 | 25 | if __name__ == '__main__': 26 | 27 | # make sure nipaprc exists and has correct permissions 28 | userrcfile = os.path.expanduser('~/.nipaprc') 29 | 30 | # read configuration 31 | cfg = configparser.ConfigParser({'prefix_list_columns': ''}) 32 | cfg.read(userrcfile) 33 | nipap_cli.cfg = cfg 34 | 35 | # setup our configuration 36 | nipap_cli.setup_connection() 37 | 38 | comp = [] 39 | 40 | # tab completion haxx. it seems that sometimes the offset is different and 41 | # so we try to search for 'nipap' to find the correct to start parsing 42 | # command line stuff at. Since nipap could be called with a path, like 43 | # './nipap', it won't always match and then we assume an offset of 2, which 44 | # is correct in the majority of cases 45 | try: 46 | offset = 1 + sys.argv.index('nipap') 47 | except: 48 | offset = 2 49 | 50 | # let shlex handle escaped whitespaces and similar 51 | args = [] 52 | for arg in sys.argv[offset::]: 53 | try: 54 | if arg != '': arg = shlex.split(arg)[0] 55 | except: 56 | sys.exit() 57 | args.append(arg) 58 | 59 | try: 60 | cmd = Command(nipap_cli.cmds, args) 61 | comp = sorted(cmd.complete()) 62 | except Exception: 63 | # handle errors silently 64 | pass 65 | 66 | for val in comp: 67 | print(val) 68 | -------------------------------------------------------------------------------- /nipap-cli/nipap_cli/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.32.7" 2 | __author__ = "Kristian Larsson, Lukas Garberg" 3 | __author_email__ = "kll@tele2.net, lukas@spritelink.net" 4 | __license__ = "MIT" 5 | __status__ = "Development" 6 | __url__ = "http://SpriteLink.github.io/NIPAP" 7 | -------------------------------------------------------------------------------- /nipap-cli/nipaprc: -------------------------------------------------------------------------------- 1 | # -------------------------------------- 2 | # NIPAP shell command configuration file 3 | # -------------------------------------- 4 | # 5 | # This file contains configuration for the NIPAP shell command. The 'nipap' 6 | # executable will look for its config in ~/.nipaprc, so to successfully 7 | # configure NIPAP, this file should be palced there and modified for your 8 | # setup. 9 | # 10 | 11 | [global] 12 | 13 | # NIPAP connection settings 14 | hostname = 127.0.0.1 15 | port = 1337 16 | username = guest 17 | password = guest 18 | #use_ssl = false 19 | 20 | # Specify a command which can be used to complete node hostnames. This will be 21 | # called when trying to complete a node hostname. 22 | # 23 | # The string "%search_string%" will be replaced by the current search string. 24 | #complete_node_cmd = node list %search_string% 25 | 26 | # Used as default VRF RT by 'nipap address add/modify/remove/view' commands 27 | # when no other VRF RT is specified on the command line. Also used as default 28 | # VRF when expanding a pool with a new prefix for the first time. 29 | # '-' means VRF 'Default' (RT: -) 30 | default_vrf_rt = - 31 | 32 | # 'nipap address list' will per default search in the following VRF RT when no 33 | # VRF RT is specified on the command line. 34 | # 'all' means that searches will include results from all VRFs 35 | default_list_vrf_rt = all 36 | 37 | # Specify custom columns for 'nipap address list' using a comma separated list 38 | # of columns. If the list is prefixed with '+' it will add these columns in 39 | # addition to the standard set of columns. 40 | # 41 | # Example to list prefix usage statistics in addition to standard columns: 42 | # 43 | # prefix_list_columns = +total_addresses,used_addresses,free_addresses 44 | # 45 | # Example to only listen VRF RT and prefix: 46 | # 47 | # prefix_list_columns = vrf_rt,prefix 48 | # 49 | # Enable OpenTelemetry tracing by uncommenting section. 50 | # [tracing] 51 | # Specify OTLP GRPC endpoint. If no endpoint is specified traces will be sent via nipapd to OpenTelemetry Collector 52 | # otlp_grpc_endpoint = http://127.0.0.1:4317 53 | # Set sampler. Valid values are always_on, always_off, parentbased_always_on, parentbased_always_off, traceidratio and parentbased_traceidratio. Default is parentbased_always_on. 54 | # otel_traces_sampler = always_on 55 | -------------------------------------------------------------------------------- /nipap-cli/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "nipap-cli" 3 | dynamic = ["version", "description"] 4 | readme = "README.rst" 5 | license = {text = "MIT"} 6 | classifiers = [ 7 | 'Development Status :: 4 - Beta', 8 | 'Intended Audience :: Developers', 9 | 'Intended Audience :: System Administrators', 10 | 'Intended Audience :: Telecommunications Industry', 11 | 'License :: OSI Approved :: MIT License', 12 | 'Natural Language :: English', 13 | 'Operating System :: POSIX :: Linux', 14 | 'Programming Language :: Python :: 3', 15 | 'Topic :: Internet' 16 | ] 17 | keywords = ["nipap"] 18 | dependencies = [ 19 | "pynipap", 20 | "IPy==1.01" 21 | ] 22 | 23 | [project.urls] 24 | Homepage = "http://SpriteLink.github.io/NIPAP" 25 | 26 | [tool.setuptools.dynamic] 27 | version = {attr = "nipap_cli.__version__"} 28 | 29 | [build-system] 30 | requires = [ 31 | "setuptools", 32 | # Need to be pinned to 0.20.1 in Ubuntu 24.04 as using the latest 0.21.2 33 | # gives a diff during .deb package build. Unfortunately the files are 34 | # generated twice - first once in a virtualenv (using the version specified 35 | # here) and then once without a virtualenv using the one from the system. 36 | # There two runs produce different outputs (wich they shouldn't) causing a 37 | # diff and the package utils to b0rk out. 38 | "docutils==0.20.1" 39 | ] 40 | build-backend = "setuptools.build_meta" 41 | -------------------------------------------------------------------------------- /nipap-cli/requirements.txt: -------------------------------------------------------------------------------- 1 | IPy==1.01 2 | pynipap 3 | -------------------------------------------------------------------------------- /nipap-cli/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from docutils.core import publish_cmdline 4 | from docutils.writers import manpage 5 | from setuptools import setup 6 | import sys 7 | 8 | # return all the extra data files 9 | def get_data_files(): 10 | 11 | # generate man pages from .rst-file 12 | try: 13 | publish_cmdline(writer=manpage.Writer(), argv=["nipap.man.rst", "nipap.1"]) 14 | except Exception as exc: 15 | print("rst2man failed to run: %s" % str(exc), file=sys.stderr) 16 | sys.exit(1) 17 | 18 | files = [ 19 | ('bin/', ['helper-nipap', 'nipap']), 20 | ('share/doc/nipap-cli/', ['bash_complete', 'nipaprc']), 21 | ('share/man/man1/', ['nipap.1']) 22 | ] 23 | 24 | return files 25 | 26 | 27 | long_desc = open('README.rst').read() 28 | short_desc = long_desc.split('\n')[0] 29 | 30 | setup( 31 | description = short_desc, 32 | long_description = long_desc, 33 | packages = ['nipap_cli'], 34 | data_files = get_data_files(), 35 | ) 36 | -------------------------------------------------------------------------------- /nipap-www/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include nipap-www.wsgi 2 | recursive-include nipapwww/static * 3 | recursive-include nipapwww/templates * 4 | -------------------------------------------------------------------------------- /nipap-www/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2011/04/18 17:14:00 lukagarb Exp $ 2 | # 3 | 4 | PYTHON=`which python3` 5 | DESTDIR=/ 6 | BUILDIR=$(CURDIR)/debian/nipap-www-build 7 | PROJECT=nipap-www 8 | 9 | all: 10 | # $(PYTHON) setup.py build 11 | @echo "make source - Create source package" 12 | @echo "make install - Install on local system" 13 | @echo "make buildrpm - Generate a rpm package" 14 | @echo "make builddeb - Generate a deb package" 15 | @echo "make bumpversion - Bump version to latest in ../NEWS file" 16 | @echo "make clean - Get rid of scratch and byte files" 17 | 18 | source: 19 | $(PYTHON) setup.py sdist 20 | 21 | install: 22 | $(PYTHON) setup.py install 23 | 24 | buildrpm: 25 | $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall 26 | 27 | builddeb: 28 | # build the source package in the parent directory 29 | # then rename it to project_version.orig.tar.gz 30 | $(PYTHON) -m build --sdist --outdir=../ 31 | rename -f 's/nipap_www-(\d.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* 32 | # build the package 33 | debuild -us -uc -sa 34 | 35 | distclean: 36 | realclean: 37 | test: 38 | check: 39 | 40 | upload: 41 | $(PYTHON) setup.py sdist upload 42 | 43 | clean: 44 | $(PYTHON) setup.py clean 45 | rm -rf .pybuild/ MANIFEST dist/ debian/$(PROJECT)* debian/files .pc/ debian/patches \ 46 | debian/.debhelper nipap_www.egg-info debian/debhelper-build-stamp 47 | find . -name '*.pyc' -delete 48 | rm -rf data/sessions/container_file/* 49 | rm -rf data/sessions/container_file_lock/* 50 | 51 | VER := $(shell head -n1 ../NEWS | awk '{print $$2}') 52 | bumpversion: 53 | # replace version number in nipapwww/__init__.py 54 | sed -i 's/\(__version__\s*= \)"[^"]\+"/\1"$(VER)"/' nipapwww/__init__.py 55 | # update debian/changelog 56 | ../utilities/news2dch.py ../NEWS debian/changelog 57 | -------------------------------------------------------------------------------- /nipap-www/debian/config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Source debconf library. 4 | . /usr/share/debconf/confmodule 5 | 6 | # TODO: we should really try to determine if nipapd is installed on this 7 | # machine here, but as packages are not yet guaranteed to be unpacked in the 8 | # config stage we cannot determine if nipapd is or is going to be installed by 9 | # looking if files exists. Can we ask apt? 10 | 11 | db_input high nipap-www/auto_secret_key || true 12 | db_go 13 | -------------------------------------------------------------------------------- /nipap-www/debian/control: -------------------------------------------------------------------------------- 1 | Source: nipap-www 2 | Section: web 3 | Priority: optional 4 | Maintainer: Lukas Garberg 5 | Build-Depends: debhelper-compat (= 13), 6 | python3-all, 7 | python3-setuptools, 8 | dh-python 9 | Standards-Version: 4.6.1 10 | 11 | Package: nipap-www 12 | Architecture: all 13 | Pre-Depends: debconf 14 | Depends: ${misc:Depends}, ${python3:Depends} 15 | XB-Python-Version: ${python:Versions} 16 | Description: web frontend for NIPAP 17 | A web UI for the NIPAP IP address planning service. 18 | -------------------------------------------------------------------------------- /nipap-www/debian/copyright: -------------------------------------------------------------------------------- 1 | Package created by Lukas Garberg (lukagarb) 2 | on Mon, 31 Oct 2011 14:58:00 +0100. 3 | 4 | Upstream Author: 5 | 6 | Kristian Larsson (kll) 7 | Lukas Garberg (lukagarb) 8 | 9 | Files: * 10 | Copyright: 11 | 2011, Tele2 AB 12 | License: MIT 13 | 14 | License: MIT 15 | Copyright (C) 2011 by Kristian Larsson, Lukas Garberg 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /nipap-www/debian/install: -------------------------------------------------------------------------------- 1 | nipap-www.wsgi etc/nipap/www 2 | -------------------------------------------------------------------------------- /nipap-www/debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Source debconf library. 4 | . /usr/share/debconf/confmodule 5 | 6 | WWW_USER='www-user' 7 | WWW_PASS=` /dev/null 2>&1 38 | if [ -e $NIPAP_CONF ]; then 39 | sed -i -e "s/http:\/\/[^:]*:[^@]*@/http:\/\/$WWW_USER@local:$WWW_PASS@/" $NIPAP_CONF 40 | fi 41 | fi 42 | fi 43 | 44 | # Set secret key in nipap.conf 45 | db_get nipap-www/auto_secret_key 46 | if [ "$RET" = "true" ]; then 47 | # Validate that there is a nipap.conf 48 | if [ -e $NIPAP_CONF ]; then 49 | if [ `grep -c secret_key $NIPAP_CONF` = "0" ]; then 50 | # There is no secret_key in nipap.conf, add it 51 | sed -i "/\[www\]/a secret_key = $WWW_SECRET_KEY" $NIPAP_CONF 52 | else 53 | CURRENT_KEY=`grep '^secret_key' $NIPAP_CONF | sed 's/^secret_key[ \t]*=[ \t]*\(.\+\)/\1/'` 54 | if [ "$CURRENT_KEY" = '{{WWW_SECRET_KEY}}' ]; then 55 | # secret_key is set to the default {{WWW_SECRET_KEY}}, replace with generated key 56 | sed -i -e "s/^secret_key[ \t]*=[ \t]*.\+$/secret_key = $WWW_SECRET_KEY/" $NIPAP_CONF 57 | fi 58 | fi 59 | fi 60 | fi 61 | -------------------------------------------------------------------------------- /nipap-www/debian/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Source debconf library. 4 | . /usr/share/debconf/confmodule 5 | 6 | ACTION=$1 7 | OLD_VERSION=$2 8 | NEW_VERSION=$3 9 | 10 | # Notify the user that actions needs to be taken when upgrading from a version 11 | # pre 0.32.0 to a version post 0.32.0 12 | if [ -n "$OLD_VERSION" ]; then 13 | OLD_MAJOR=`echo $OLD_VERSION | cut -d . -f 1` 14 | OLD_MINOR=`echo $OLD_VERSION | cut -d . -f 2` 15 | 16 | if [ \( $OLD_MAJOR -le 0 \) -a \( $OLD_MINOR -lt 32 \) ]; then 17 | db_input high nipap-www/python3-warning || true 18 | db_go 19 | fi 20 | fi 21 | -------------------------------------------------------------------------------- /nipap-www/debian/py3dist-overrides: -------------------------------------------------------------------------------- 1 | pynipap python3-pynipap 2 | nipap nipap-common 3 | Flask python3-flask (>= 2.0.0) 4 | -------------------------------------------------------------------------------- /nipap-www/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ --with python3 --buildsystem=pybuild 5 | -------------------------------------------------------------------------------- /nipap-www/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /nipap-www/debian/source/options: -------------------------------------------------------------------------------- 1 | # Keep a few files out of the debian package 2 | extend-diff-ignore = "(^|/)(test.ini|Makefile|data/sessions/container_file/.*|data/sessions/container_file_lock/.*|requirements.txt|entrypoint.sh)$" 3 | -------------------------------------------------------------------------------- /nipap-www/debian/templates: -------------------------------------------------------------------------------- 1 | Template: nipap-www/autouser 2 | Type: boolean 3 | Default: false 4 | Description: Automatically create user for web interface? 5 | The NIPAP backend daemon, nipapd, appears to be installed on this system. 6 | Would you like to add a user to the local auth database of nipapd for the web 7 | interface? The configuration file for the web interface will be updated with 8 | the new user so that the web interface becomes functional. 9 | . 10 | Creating a user will get you up and running with the web interface. If you 11 | answer No, you will need to manually create a user and configure the web 12 | interface with those credentials. 13 | 14 | Template: nipap-www/auto_secret_key 15 | Type: boolean 16 | Default: false 17 | Description: Automatically configure randomized secret_key? 18 | The NIPAP web UI requires a secret key to be configured in the www-section 19 | of nipap.conf. 20 | 21 | Template: nipap-www/python3-warning 22 | Type: note 23 | Description: The NIPAP web UI is now migrated to Python 3. 24 | Depending on how it is served, some further action might be needed for it to 25 | function after the upgrade. If it is served with Apache httpd and mod_wsgi as 26 | described in the installation guide, the Python 3 version of mod_wsgi needs to 27 | be installed: 28 | . 29 | apt install libapache2-mod-wsgi-py3 30 | -------------------------------------------------------------------------------- /nipap-www/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # If WWW_SECRET_KEY is not set, generate random string 4 | if [ ! -v WWW_SECRET_KEY ]; then 5 | export WWW_SECRET_KEY=`tr -dc A-Za-z0-9 /etc/apache2/sites-available/000-default.conf 23 | 24 | WSGIScriptAlias / /etc/nipap/www/nipap-www.wsgi 25 | ErrorLog \${APACHE_LOG_DIR}/error.log 26 | CustomLog \${APACHE_LOG_DIR}/access.log combined 27 | 28 | Require all granted 29 | 30 | 31 | EOF 32 | 33 | # Start apache 34 | source /etc/apache2/envvars 35 | exec /usr/sbin/apache2 -DFOREGROUND 36 | -------------------------------------------------------------------------------- /nipap-www/nipap-www.wsgi: -------------------------------------------------------------------------------- 1 | # 2 | # Set up a wsgi environment for mod_wsgi 3 | # 4 | 5 | import os, sys 6 | 7 | from nipapwww import create_app 8 | 9 | application = create_app() 10 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.32.7" 2 | __author__ = "Kristian Larsson, Lukas Garberg" 3 | __author_email__ = "kll@tele2.net, lukas@spritelink.net" 4 | __license__ = "MIT" 5 | __status__ = "Development" 6 | __url__ = "http://SpriteLink.github.io/NIPAP" 7 | 8 | 9 | def create_app(test_config=None): 10 | 11 | # Moved imports here to be able to import this module without having the 12 | # dependencies installed. Relevant during initial package build. 13 | import os 14 | from flask import Flask, redirect, url_for 15 | from nipap.nipapconfig import NipapConfig, NipapConfigError 16 | import pynipap 17 | 18 | # create and configure the app 19 | app = Flask(__name__, instance_relative_config=True) 20 | app.config.from_mapping( 21 | NIPAP_CONFIG_PATH="/etc/nipap/nipap.conf", 22 | SESSION_REFRESH_EACH_REQUEST=False 23 | ) 24 | if "NIPAP_CONFIG_PATH" in os.environ: 25 | app.config["NIPAP_CONFIG_PATH"] = os.environ["NIPAP_CONFIG_PATH"] 26 | 27 | # load NIPAP config file 28 | nipap_config = NipapConfig(app.config["NIPAP_CONFIG_PATH"]) 29 | for cfg_key, cfg_value in dict(nipap_config.items("www")).items(): 30 | app.config[cfg_key.upper()] = cfg_value 31 | 32 | # ensure the instance folder exists 33 | try: 34 | os.makedirs(app.instance_path) 35 | except OSError: 36 | pass 37 | 38 | # configure pynipap 39 | pynipap.xmlrpc_uri = app.config["XMLRPC_URI"] 40 | 41 | # configure tracing 42 | if nipap_config.has_section("tracing"): 43 | try: 44 | import nipap.tracing 45 | from opentelemetry.instrumentation.wsgi import OpenTelemetryMiddleware 46 | from opentelemetry.sdk.trace.sampling import _KNOWN_SAMPLERS 47 | 48 | sampler = None 49 | 50 | if nipap_config.has_option("tracing", "otel_traces_sampler"): 51 | trace_sampler = nipap_config.get("tracing", "otel_traces_sampler") 52 | if trace_sampler not in _KNOWN_SAMPLERS: 53 | raise NipapConfigError(f"Unknown otel_traces_sampler '{trace_sampler}'. Valid samplers are: {_KNOWN_SAMPLERS}") 54 | sampler = _KNOWN_SAMPLERS[trace_sampler] 55 | 56 | if nipap_config.has_option("tracing", "otlp_grpc_endpoint"): 57 | nipap.tracing.init_tracing("nipap-www", nipap_config.get("tracing", "otlp_grpc_endpoint"), sampler) 58 | elif nipap_config.has_option("tracing", "otlp_http_endpoint"): 59 | nipap.tracing.init_tracing("nipap-www", nipap_config.get("tracing", "otlp_http_endpoint"), sampler, False) 60 | else: 61 | raise NipapConfigError("Tracing enabled but no OTLP endpoint configured") 62 | 63 | app.wsgi_app = OpenTelemetryMiddleware(app.wsgi_app) 64 | except KeyError: 65 | pass 66 | except ImportError: 67 | pass 68 | 69 | # Set up blueprints 70 | from . import auth, ng, prefix, static, version, xhr 71 | app.register_blueprint(auth.bp) 72 | app.register_blueprint(ng.bp) 73 | app.register_blueprint(prefix.bp) 74 | app.register_blueprint(static.bp) 75 | app.register_blueprint(version.bp) 76 | app.register_blueprint(xhr.bp) 77 | 78 | @app.route('/') 79 | def index(): 80 | return redirect(url_for('prefix.list')) 81 | 82 | return app 83 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/auth.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | from flask import ( 4 | Blueprint, current_app, g, redirect, render_template, request, session, 5 | url_for 6 | ) 7 | 8 | from nipap.authlib import AuthError, AuthFactory 9 | 10 | from pynipap import AuthOptions 11 | 12 | 13 | bp = Blueprint('auth', __name__, url_prefix='/auth') 14 | 15 | 16 | def login_required(view): 17 | @functools.wraps(view) 18 | def wrapped_view(**kwargs): 19 | if session.get("user") is None: 20 | session['path_before_login'] = request.full_path 21 | return redirect(url_for('auth.login')) 22 | 23 | return view(**kwargs) 24 | 25 | return wrapped_view 26 | 27 | 28 | @bp.before_app_request 29 | def setup_auth(): 30 | """ Set up the environment 31 | """ 32 | 33 | if current_app.config.get("WELCOME_MESSAGE"): 34 | g.welcome_message = current_app.config.get("WELCOME_MESSAGE") 35 | 36 | # set authentication options 37 | o = AuthOptions({ 38 | 'username': session.get('user'), 39 | 'full_name': session.get('full_name'), 40 | 'authoritative_source': 'nipap', 41 | 'readonly': session.get('readonly') 42 | }) 43 | 44 | 45 | @bp.route('/login', methods=('GET', 'POST')) 46 | def login(): 47 | """ Show login form. 48 | """ 49 | 50 | if request.method != 'POST': 51 | return render_template('login.html') 52 | 53 | # Verify username and password. 54 | try: 55 | auth_fact = AuthFactory() 56 | auth = auth_fact.get_auth(request.form['username'], 57 | request.form['password'], 58 | 'nipap') 59 | if not auth.authenticate(): 60 | g.error = 'Invalid username or password' 61 | return render_template('login.html') 62 | except AuthError: 63 | g.error = 'Authentication error' 64 | return render_template('login.html') 65 | 66 | # Mark user as logged in 67 | path_before_login = session.get('path_before_login') 68 | session.clear() 69 | session['user'] = auth.username 70 | session['full_name'] = auth.full_name 71 | session['readonly'] = auth.readonly 72 | session['current_vrfs'] = {} 73 | session.permanent = True 74 | 75 | # Send user back to the page he originally wanted to get to 76 | if path_before_login: 77 | return redirect(path_before_login) 78 | 79 | else: 80 | # if previous target is unknown just send the user to a welcome page 81 | return redirect(url_for('prefix.list')) 82 | 83 | 84 | @bp.route('/logout', methods=('GET',)) 85 | def logout(): 86 | """ Log out the user and display a confirmation message. 87 | """ 88 | 89 | # remove session 90 | session.clear() 91 | g.logged_out = True 92 | 93 | return render_template('login.html') 94 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/ng.py: -------------------------------------------------------------------------------- 1 | """ Controller for handling pure AngularJS pages 2 | 3 | Used during the transition phase when the NIPAP web UI is built up 4 | partly by legacy Jinja2/jQuery and AngularJS components. At this stage 5 | each section of the NIPAP page (VRF, Prefix, Pool) gets its own action, 6 | basically just to avoid handling the hilighting of the active section 7 | in the top menu in AngularJS. 8 | """ 9 | 10 | from flask import Blueprint, redirect, render_template, url_for 11 | 12 | from .auth import login_required 13 | 14 | bp = Blueprint('ng', __name__, url_prefix='/ng') 15 | 16 | 17 | @bp.route('/') 18 | def index(): 19 | return redirect(url_for('ng.prefix')) 20 | 21 | 22 | @bp.route('/pool') 23 | @login_required 24 | def pool(): 25 | """ Action for handling the pool-section 26 | """ 27 | return render_template('/ng-pool.html') 28 | 29 | 30 | @bp.route('/prefix') 31 | @login_required 32 | def prefix(): 33 | """ Action for handling the prefix-section 34 | """ 35 | return render_template('/ng-prefix.html') 36 | 37 | 38 | @bp.route('/vrf') 39 | @login_required 40 | def vrf(): 41 | """ Action for handling the vrf-section 42 | """ 43 | return render_template('/ng-vrf.html') 44 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/prefix.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint, g, render_template 2 | 3 | from .auth import login_required 4 | 5 | bp = Blueprint('prefix', __name__, url_prefix='/prefix') 6 | 7 | 8 | @bp.route('/list') 9 | @login_required 10 | def list(): 11 | """ Prefix list. 12 | """ 13 | 14 | g.search_opt_parent = "all" 15 | g.search_opt_child = "none" 16 | 17 | return render_template('/prefix_list.html') 18 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static.py: -------------------------------------------------------------------------------- 1 | """ Controller for serving static content 2 | """ 3 | 4 | from flask import Blueprint, send_from_directory 5 | 6 | bp = Blueprint('static', __name__, url_prefix='/') 7 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Define nipapApp angular application 3 | */ 4 | var nipapApp = angular.module('nipapApp', [ 5 | 'ngRoute', 6 | 'ui.bootstrap', 7 | 'ngTagsInput', 8 | 'nipapApp.controllers', 9 | 'nipapApp.directives', 10 | 'nipapApp.filters', 11 | 'nipapApp.services', 12 | 'infinite-scroll' 13 | ]); 14 | 15 | /* 16 | * App configuration 17 | */ 18 | nipapApp.config(function($routeProvider, $uibTooltipProvider, $sceProvider, $locationProvider) { 19 | 20 | /* 21 | * Define application routes 22 | */ 23 | $routeProvider 24 | .when('/pool/add', { 25 | 'controller': 'PoolAddController', 26 | 'templateUrl': '/static/templates/pool_add.html' 27 | }) 28 | .when('/pool/edit/:pool_id', { 29 | 'controller': 'PoolEditController', 30 | 'templateUrl': '/static/templates/pool_edit.html' 31 | }) 32 | .when('/pool/list', { 33 | 'controller': 'PoolListController', 34 | 'templateUrl': '/static/templates/pool_list.html' 35 | }) 36 | .when('/prefix/add/:allocation_method/:allocation_method_parameter?', { 37 | 'controller': 'PrefixAddController', 38 | 'templateUrl': '/static/templates/prefix_add.html' 39 | }) 40 | .when('/prefix/edit/:prefix_id', { 41 | 'controller': 'PrefixEditController', 42 | 'templateUrl': '/static/templates/prefix_edit.html' 43 | }) 44 | .when('/vrf/add', { 45 | 'controller': 'VRFAddController', 46 | 'templateUrl': '/static/templates/vrf_add.html' 47 | }) 48 | .when('/vrf/edit/:vrf_id', { 49 | 'controller': 'VRFEditController', 50 | 'templateUrl': '/static/templates/vrf_edit.html' 51 | }) 52 | .when('/vrf/list', { 53 | 'controller': 'VRFListController', 54 | 'templateUrl': '/static/templates/vrf_list.html' 55 | }); 56 | 57 | /* 58 | * Default options for tooltips 59 | */ 60 | $uibTooltipProvider 61 | .options({ 62 | 'placement': 'bottom', 63 | 'popupDelay': 100 64 | }); 65 | 66 | /* 67 | * Disable Strict Contextual Escaping on the application. At 68 | * this stage where the application is partly implemented 69 | * outside AngularJS but still using AngularJS directives, it's 70 | * really difficult to get things to work with the SCE feature 71 | * enabled. Re-enable again when more of the application is 72 | * implemented in AngularJS. 73 | */ 74 | $sceProvider.enabled(false); 75 | 76 | /* 77 | * Remove default hash prefix ("!") introduced in AngularJS 1.6 78 | */ 79 | $locationProvider.hashPrefix(""); 80 | 81 | }); 82 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/css/jquery.tagit.css: -------------------------------------------------------------------------------- 1 | ul.tagit { 2 | padding: 1px 5px; 3 | overflow: auto; 4 | margin-left: inherit; /* usually we don't want the regular ul margins. */ 5 | margin-right: inherit; 6 | } 7 | ul.tagit li { 8 | display: block; 9 | float: left; 10 | margin: 2px 5px 2px 0; 11 | } 12 | ul.tagit li.tagit-choice { 13 | position: relative; 14 | line-height: inherit; 15 | } 16 | 17 | ul.tagit li.tagit-choice-read-only { 18 | padding: .2em .5em .2em .5em; 19 | } 20 | 21 | ul.tagit li.tagit-choice-editable { 22 | padding: .2em 18px .2em .5em; 23 | } 24 | 25 | ul.tagit li.tagit-new { 26 | padding: .25em 4px .25em 0; 27 | } 28 | 29 | ul.tagit li.tagit-choice a.tagit-label { 30 | cursor: pointer; 31 | text-decoration: none; 32 | } 33 | ul.tagit li.tagit-choice .tagit-close { 34 | cursor: pointer; 35 | position: absolute; 36 | right: .1em; 37 | top: 50%; 38 | margin-top: -8px; 39 | line-height: 17px; 40 | } 41 | 42 | /* used for some custom themes that don't need image icons */ 43 | ul.tagit li.tagit-choice .tagit-close .text-icon { 44 | display: none; 45 | } 46 | 47 | ul.tagit li.tagit-choice input { 48 | display: block; 49 | float: left; 50 | margin: 2px 5px 2px 0; 51 | } 52 | ul.tagit input[type="text"] { 53 | -moz-box-sizing: border-box; 54 | -webkit-box-sizing: border-box; 55 | box-sizing: border-box; 56 | 57 | -moz-box-shadow: none; 58 | -webkit-box-shadow: none; 59 | box-shadow: none; 60 | 61 | border: none; 62 | margin: 0; 63 | padding: 0; 64 | width: inherit; 65 | background-color: inherit; 66 | outline: none; 67 | } 68 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/css/ng-tags-input-2.1.1.min.css: -------------------------------------------------------------------------------- 1 | tags-input{display:block}tags-input *,tags-input :after,tags-input :before{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}tags-input .host{position:relative;margin-top:5px;margin-bottom:5px;height:100%}tags-input .host:active{outline:0}tags-input .tags{-moz-appearance:textfield;-webkit-appearance:textfield;padding:1px;overflow:hidden;word-wrap:break-word;cursor:text;background-color:#fff;border:1px solid #a9a9a9;box-shadow:1px 1px 1px 0 #d3d3d3 inset;height:100%}tags-input .tags.focused{outline:0;-webkit-box-shadow:0 0 3px 1px rgba(5,139,242,.6);-moz-box-shadow:0 0 3px 1px rgba(5,139,242,.6);box-shadow:0 0 3px 1px rgba(5,139,242,.6)}tags-input .tags .tag-list{margin:0;padding:0;list-style-type:none}tags-input .tags .tag-item{margin:2px;padding:0 5px;display:inline-block;float:left;font:14px "Helvetica Neue",Helvetica,Arial,sans-serif;height:26px;line-height:25px;border:1px solid #acacac;border-radius:3px;background:-webkit-linear-gradient(top,#f0f9ff 0,#cbebff 47%,#a1dbff 100%);background:linear-gradient(to bottom,#f0f9ff 0,#cbebff 47%,#a1dbff 100%)}tags-input .tags .tag-item.selected{background:-webkit-linear-gradient(top,#febbbb 0,#fe9090 45%,#ff5c5c 100%);background:linear-gradient(to bottom,#febbbb 0,#fe9090 45%,#ff5c5c 100%)}tags-input .tags .tag-item .remove-button{margin:0 0 0 5px;padding:0;border:none;background:0 0;cursor:pointer;vertical-align:middle;font:700 16px Arial,sans-serif;color:#585858}tags-input .tags .tag-item .remove-button:active{color:red}tags-input .tags .input{border:0;outline:0;margin:2px;padding:0;padding-left:5px;float:left;height:26px;font:14px "Helvetica Neue",Helvetica,Arial,sans-serif}tags-input .tags .input.invalid-tag{color:red}tags-input .tags .input::-ms-clear{display:none}tags-input.ng-invalid .tags{-webkit-box-shadow:0 0 3px 1px rgba(255,0,0,.6);-moz-box-shadow:0 0 3px 1px rgba(255,0,0,.6);box-shadow:0 0 3px 1px rgba(255,0,0,.6)}tags-input .autocomplete{margin-top:5px;position:absolute;padding:5px 0;z-index:999;width:100%;background-color:#fff;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2)}tags-input .autocomplete .suggestion-list{margin:0;padding:0;list-style-type:none}tags-input .autocomplete .suggestion-item{padding:5px 10px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font:16px "Helvetica Neue",Helvetica,Arial,sans-serif;color:#000;background-color:#fff}tags-input .autocomplete .suggestion-item.selected,tags-input .autocomplete .suggestion-item.selected em{color:#fff;background-color:#0097cf}tags-input .autocomplete .suggestion-item em{font:normal bold 16px "Helvetica Neue",Helvetica,Arial,sans-serif;color:#000;background-color:#fff} -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/favicon.ico -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/filters.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Filters for the NIPAP AngularJS app 3 | */ 4 | 5 | var nipapAppFilters = angular.module('nipapApp.filters', []); 6 | 7 | /* 8 | * Filter to return number of entries in 'dict', ie JavaScript Object 9 | */ 10 | nipapAppFilters.filter('dictSize', function () { 11 | return function(object) { 12 | return Object.keys(object).length; 13 | } 14 | }); 15 | 16 | 17 | /* 18 | * Filter to return number of entries in 'dict', ie JavaScript Object 19 | */ 20 | nipapAppFilters.filter('notEmpty', function () { 21 | return function(object) { 22 | return !!(object && Object.keys(object).length); 23 | }; 24 | }); 25 | 26 | 27 | /* 28 | * Filter to format tags for tag popover 29 | */ 30 | nipapAppFilters.filter('popoverFormatTags', function () { 31 | return function(object) { 32 | return '
Tags:
' + Object.keys(object).join('
') + '
'; 33 | }; 34 | }); 35 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/add_prefix_from_pool_notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/add_prefix_from_pool_notice.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/add_prefix_from_prefix_notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/add_prefix_from_prefix_notice.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/back_disabled.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/back_disabled.jpg -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/back_enabled.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/back_enabled.jpg -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/comments-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/comments-16.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/display_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/display_menu.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/expand_pool_notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/expand_pool_notice.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/forward_disabled.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/forward_disabled.jpg -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/forward_enabled.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/forward_enabled.jpg -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/loading.gif -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/sort_asc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/sort_asc.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/sort_asc_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/sort_asc_disabled.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/sort_both.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/sort_both.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/sort_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/sort_desc.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/sort_desc_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/sort_desc_disabled.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/tag-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/tag-16.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/images/x-mark-3-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nipap-www/nipapwww/static/images/x-mark-3-16.png -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/ng-infinite-scroll.min.js: -------------------------------------------------------------------------------- 1 | /* ng-infinite-scroll - v1.0.0 - 2013-02-23 2 | Copyright (c) 2012 Brandon Tilley 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE.*/ 24 | var mod;mod=angular.module("infinite-scroll",[]),mod.directive("infiniteScroll",["$rootScope","$window","$timeout",function(i,n,e){return{link:function(t,l,o){var r,c,f,a;return n=angular.element(n),f=0,null!=o.infiniteScrollDistance&&t.$watch(o.infiniteScrollDistance,function(i){return f=parseInt(i,10)}),a=!0,r=!1,null!=o.infiniteScrollDisabled&&t.$watch(o.infiniteScrollDisabled,function(i){return a=!i,a&&r?(r=!1,c()):void 0}),c=function(){var e,c,u,d;return d=n.height()+n.scrollTop(),e=l.offset().top+l.height(),c=e-d,u=n.height()*f>=c,u&&a?i.$$phase?t.$eval(o.infiniteScroll):t.$apply(o.infiniteScroll):u?r=!0:void 0},n.on("scroll",c),t.$on("$destroy",function(){return n.off("scroll",c)}),e(function(){return o.infiniteScrollImmediateCheck?t.$eval(o.infiniteScrollImmediateCheck)?c():void 0:c()},0)}}}]); -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/pool_add.html: -------------------------------------------------------------------------------- 1 |
2 | Pool administration —> add pool 3 |
4 | 5 | 6 | 7 |
8 |
9 |
10 |

Result

11 |
12 | The pool {{ pool.name }} was successfully added. 13 |
14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/pool_list.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | Pools is simply a time-saver for getting new prefixes. One or more 4 | larger prefixes are grouped together in a pool and when you want a new 5 | prefix, you can request one and the system will automatically allocate 6 | the first available one in that pool, for you.

7 | Every pool can have a default type and default prefix-length which are 8 | used as the default for new prefixes that you request. You can 9 | naturally override the defaults on a per request basis.

10 | This page is used to administrate pools. If you want to get a new 11 | prefix, please go to the "prefixes" page and click "Add prefix". 12 |
13 |
14 | 15 |
16 | Add pool 17 |
18 | 19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 47 | 52 | 53 | 54 |
NameDescriptionDefault type4 / 6
{{ pool.name }}{{ pool.description }}{{ pool.default_type }}{{ pool.ipv4_default_prefix_length || '-' }} / {{ pool.ipv6_default_prefix_length || '-' }} 36 |
37 |
38 | 39 |
40 | 45 |
46 |
48 | 49 | 50 | 51 |
55 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/pool_selector.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
NameDescriptionDefault type4 / 6
{{ pool.name }}{{ pool.description }}{{ pool.default_type }}{{ pool.ipv4_default_prefix_length || '-' }} / {{ pool.ipv6_default_prefix_length || '-' }}
21 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/pool_selector_popup.html: -------------------------------------------------------------------------------- 1 | 26 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/prefix_edit.html: -------------------------------------------------------------------------------- 1 |
2 | Prefix administration —> edit prefix 3 |
4 | 5 | 6 | 7 |
8 |
9 |
10 |

Result

11 |
12 | The prefix {{ prefix.prefix }} was successfully edited. 13 |
14 |
15 |
16 |
17 | 18 | 23 |
24 |
25 |

Statistics for prefix {{ prefix.prefix }}

26 | 27 |
28 |
29 |
30 |
31 |
32 | 33 | Prefix {{ prefix.prefix }} contains {{ prefix.total_addresses }} 34 | addresses out of which {{ prefix.used_addresses }} are 35 | in use while {{ prefix.free_addresses }} are free, 36 | representing a usage of 37 | {{ (prefix.used_addresses / prefix.total_addresses * 100) | number: 1 }}%. 38 |
39 |
40 |
41 | 42 |
43 |
44 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/vrf_add.html: -------------------------------------------------------------------------------- 1 |
2 | VRF administration —> add VRF 3 |
4 | 5 | 6 | 7 |
8 |
9 |
10 |

Result

11 |
12 | The VRF {{ vrf.rt }} was successfully added. 13 |
14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/vrf_edit.html: -------------------------------------------------------------------------------- 1 |
2 | VRF administration —> edit VRF 3 |
4 | 5 | 6 | 7 |
8 |
9 |
10 |

Result

11 |
12 | The VRF {{ vrf.rt }} was successfully edited. 13 |
14 |
15 |
16 |
17 | 18 | 19 |
20 |
21 |

Statistics for VRF {{ vrf.name }}

22 | 23 |
24 |
25 |
26 | IPv4 27 |
28 |
29 | No IPv4 prefixes in VRF. 30 | 31 | 32 | VRF {{ vrf.name }} contains {{ vrf.num_prefixes_v4 }} 33 | IPv4 prefixes containing a total of {{ vrf.total_addresses_v4 }} 34 | addresses. {{ vrf.used_addresses_v4 }} of those are in use 35 | while {{ vrf.free_addresses_v4 }} are free, representing a 36 | usage of {{ ( vrf.used_addresses_v4 / vrf.total_addresses_v4 * 100) | number: 1 }}%. 37 | 38 |
39 |
40 |
41 | 42 |
43 | 44 |
45 |
46 |
47 | IPv6 48 |
49 |
50 | No IPv6 prefixes in VRF. 51 | 52 | 53 | VRF {{ vrf.name }} contains {{ vrf.num_prefixes_v6 }} 54 | IPv6 prefixes containing a total of {{ vrf.total_addresses_v6 }} 55 | addresses. {{ vrf.used_addresses_v6 }} of those are in use 56 | while {{ vrf.free_addresses_v6 }} are free, representing a 57 | usage of {{ ( vrf.used_addresses_v6 / vrf.total_addresses_v6 * 100) | number: 1 }}%. 58 | 59 |
60 |
61 |
62 |
63 |
64 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/vrf_form.html: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 | 9 |
10 |
11 |

12 | Properties of new VRF 13 |

14 |

15 | Properties of VRF {{ vrf.name }} 16 |

17 | 18 |
19 |
20 |
21 | RT 22 |
23 |
24 | 28 |
29 |
30 |
31 | 32 |
33 | 34 |
35 |
36 |
37 | Name * 38 |
39 |
40 | 44 |
45 |
46 |
47 | 48 |
49 | 50 |
51 |
52 |
53 | Description 54 |
55 |
56 | 61 |
62 |
63 |
64 | 65 |
66 | 67 |
68 |
69 |
70 | Tags 71 |
72 |
73 | 74 |
75 |
76 |
77 | 78 |
79 | 80 |
81 |
82 |
83 | Extra Attributes 84 |
85 |
86 | 87 | 88 | 89 | 92 | 95 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 111 | 112 |
90 | = 91 | 93 | 94 | 96 | 99 |
107 | 110 |
113 |
114 |
115 |
116 | 117 |
118 | 119 |
120 |
121 |
122 |
123 | 124 | 125 |
126 |
127 |
128 |
129 |
130 |
131 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/vrf_list.html: -------------------------------------------------------------------------------- 1 |
2 | Add VRF 3 |
4 | 5 |
6 |
7 | A prefix must be unique within the VRF where it is stored. Multiple 8 | VRFs can thus be used to document the address space which contain 9 | overlapping addresses. 10 |

11 |
12 |
13 | 14 |
15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 41 | 42 | 43 |
RTNameDescription
{{ vrf.rt }}{{ vrf.name }}{{ vrf.description }} 30 |
31 |
32 | 33 |
34 | 39 |
40 |
44 |
 
45 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/static/templates/vrf_selector.html: -------------------------------------------------------------------------------- 1 | 28 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |
8 |
9 |
10 | Log in 11 |
12 |
13 | {% if g.welcome_message is defined %} 14 |
15 |
16 |
17 |
{{g.welcome_message}}
18 |
19 |
20 |
21 | {% endif %} 22 |
23 |
24 |
Username
25 |
26 |
27 |
28 |
29 |
30 |
31 |
Password
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | 47 | {% if g.error %} 48 |
49 |
50 |
51 |

Result

52 |
53 | {{ g.error }} 54 |
55 |
56 |
57 |
58 | {% endif %} 59 | 60 | {% if g.logged_out %} 61 |
62 |
63 |
64 |

Result

65 |
66 | Logged out 67 |
68 |
69 |
70 |
71 | {% endif %} 72 | 73 | {% endblock %} 74 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/templates/ng-pool.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% set page = 'pools' %} 3 | 4 | {% block content %}{% raw %} 5 | 6 |
7 | 8 | {% endraw %}{% endblock %} 9 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/templates/ng-prefix.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% set page = 'prefixes' %} 3 | 4 | {% block content %}{% raw %} 5 | 6 |
7 | 8 | {% endraw %}{% endblock %} 9 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/templates/ng-vrf.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% set page = 'vrfs' %} 3 | 4 | {% block content %}{% raw %} 5 | 6 |
7 | 8 | {% endraw %}{% endblock %} 9 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/templates/version.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 | 5 |
Version
6 | 7 |
8 |
9 | 10 |

Version information

11 | 12 |
13 |
14 |
15 | nipap-www 16 |
17 |
18 | {{ g.www_version }} 19 |
20 |
21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | pynipap 29 |
30 |
31 | {{ g.pynipap_version }} 32 |
33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 | nipapd 42 |
43 |
44 | {{ g.nipapd_version }} 45 |
46 |
47 |
48 | 49 |
50 | 51 |
52 |
53 |
54 | nipap db schema 55 |
56 |
57 | {{ g.nipap_db_version }} 58 |
59 |
60 |
61 |
62 |
63 | 64 | {% endblock %} 65 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/tracing.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | from flask import session 4 | 5 | try: 6 | from opentelemetry import trace 7 | from opentelemetry.trace import INVALID_SPAN 8 | 9 | def create_span(view): 10 | @functools.wraps(view) 11 | def wrapped_view(**kwargs): 12 | current_span = trace.get_current_span() 13 | if current_span != INVALID_SPAN: 14 | if session.get("user") is None: 15 | current_span.set_attribute("username", "unknown") 16 | else: 17 | current_span.set_attribute("username", session.get("user")) 18 | return view(**kwargs) 19 | 20 | return wrapped_view 21 | except ImportError: 22 | def create_span(view): 23 | @functools.wraps(view) 24 | def wrapped_view(**kwargs): 25 | return view(**kwargs) 26 | 27 | return wrapped_view 28 | -------------------------------------------------------------------------------- /nipap-www/nipapwww/version.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint, g, render_template 2 | 3 | import nipapwww 4 | 5 | import pynipap 6 | 7 | bp = Blueprint('version', __name__, url_prefix='/version') 8 | 9 | 10 | @bp.before_app_request 11 | def set_version(): 12 | """ Add version 13 | """ 14 | g.www_version = nipapwww.__version__ 15 | 16 | 17 | @bp.route('/') 18 | def show_version(): 19 | """ Display NIPAP version info 20 | """ 21 | g.pynipap_version = pynipap.__version__ 22 | try: 23 | g.nipapd_version = pynipap.nipapd_version() 24 | except pynipap.NipapError: 25 | g.nipapd_version = 'unknown' 26 | 27 | g.nipap_db_version = pynipap.nipap_db_version() 28 | 29 | return render_template('/version.html') 30 | -------------------------------------------------------------------------------- /nipap-www/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "nipap-www" 3 | description = "Web frontend for NIPAP" 4 | dynamic = ["version"] 5 | license = {text = "MIT"} 6 | classifiers = [ 7 | 'Development Status :: 4 - Beta', 8 | 'Intended Audience :: Developers', 9 | 'Intended Audience :: System Administrators', 10 | 'License :: OSI Approved :: MIT License', 11 | 'Natural Language :: English', 12 | 'Operating System :: POSIX :: Linux', 13 | 'Programming Language :: Python :: 3' 14 | ] 15 | keywords = ["nipap"] 16 | dependencies = [ 17 | "Flask==3.0.3", 18 | "Jinja2==3.1.5", 19 | "nipap", 20 | "pynipap", 21 | ] 22 | 23 | [project.optional-dependencies] 24 | instrumentation = [ 25 | "opentelemetry-api==1.29.0", 26 | "opentelemetry-exporter-otlp==1.29.0", 27 | "opentelemetry-exporter-otlp-proto-common==1.29.0", 28 | "opentelemetry-exporter-otlp-proto-grpc==1.29.0", 29 | "opentelemetry-exporter-otlp-proto-http==1.29.0", 30 | "opentelemetry-instrumentation==0.50b0", 31 | "opentelemetry-instrumentation-flask==0.50b0", 32 | "opentelemetry-instrumentation-wsgi==0.50b0", 33 | "opentelemetry-proto==1.29.0", 34 | "opentelemetry-sdk==1.29.0", 35 | "opentelemetry-semantic-conventions==0.50b0", 36 | "opentelemetry-util-http==0.50b0" 37 | ] 38 | 39 | [project.urls] 40 | Homepage = "http://SpriteLink.github.io/NIPAP" 41 | 42 | [tool.setuptools] 43 | packages = ["nipapwww"] 44 | 45 | [tool.setuptools.dynamic] 46 | version = {attr = "nipapwww.__version__"} 47 | 48 | [build-system] 49 | requires = [ 50 | "setuptools" 51 | ] 52 | build-backend = "setuptools.build_meta" 53 | -------------------------------------------------------------------------------- /nipap-www/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | data_files=[ 5 | ('share/nipap', ['nipap-www.wsgi', ]), 6 | ], 7 | ) 8 | -------------------------------------------------------------------------------- /nipap/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst MANIFEST.in 2 | include *.man.rst 3 | include requirements.txt 4 | -------------------------------------------------------------------------------- /nipap/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2011/04/18 17:14:00 lukagarb Exp $ 2 | # 3 | 4 | PYTHON=`which python3` 5 | DESTDIR=/ 6 | BUILDIR=$(CURDIR)/debian/python-nipap-build 7 | PROJECT=nipap 8 | 9 | all: 10 | # $(PYTHON) setup.py build 11 | @echo "make source - Create source package" 12 | @echo "make install - Install on local system" 13 | @echo "make buildrpm - Generate a rpm package" 14 | @echo "make builddeb - Generate a deb package" 15 | @echo "make bumpversion - Bump version to latest in ../NEWS file" 16 | @echo "make clean - Get rid of scratch and byte files" 17 | 18 | source: sql2py 19 | $(PYTHON) setup.py sdist 20 | 21 | install: sql2py 22 | $(PYTHON) setup.py install 23 | 24 | buildrpm: sql2py 25 | $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall 26 | 27 | builddeb: sql2py 28 | # build the source package in the parent directory 29 | # then rename it to project_version.orig.tar.gz 30 | $(PYTHON) -m build --sdist --outdir=../ 31 | rename -f 's/$(PROJECT)-(\d.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* 32 | # build the package 33 | debuild -us -uc 34 | 35 | distclean: 36 | realclean: 37 | test: 38 | check: 39 | 40 | upload: 41 | $(PYTHON) setup.py sdist upload 42 | 43 | clean: 44 | $(PYTHON) setup.py clean 45 | rm -rf .pybuild/ MANIFEST dist/ debian/tmp debian/nipap-common \ 46 | debian/$(PROJECT) debian/nipapd debian/files .pc/ nipapd.8* \ 47 | nipap-passwd.1* debian/nipapd.debhelper.log \ 48 | debian/nipapd.postinst.debhelper debian/nipapd.postrm.debhelper \ 49 | debian/nipapd.prerm.debhelper debian/nipapd.substvars \ 50 | debian/nipap-common.debhelper.log \ 51 | debian/nipap-common.postinst.debhelper \ 52 | debian/nipap-common.prerm.debhelper debian/nipap-common.substvars \ 53 | debian/.debhelper debian/debhelper-build-stamp nipap.egg-info/ build/ 54 | find . -name '*.pyc' -delete 55 | 56 | VER := $(shell head -n1 ../NEWS | awk '{print $$2}') 57 | DB_VER := $(shell grep "COMMENT ON DATABASE %s IS" sql/ip_net.plsql | sed 's/.*version: \([0-9]\+\).*/\1/') 58 | bumpversion: 59 | # update debian package nipapd's config and postinst script with current db 60 | # version 61 | sed -i 's/^CURRENT_DB_VERSION.*/CURRENT_DB_VERSION=$(DB_VER)/' debian/nipapd.config debian/nipapd.postinst 62 | # replace version & db_version number in nipap/__init__.py 63 | sed -i 's/\(__version__\s*= \)"[^"]\+"/\1"$(VER)"/' nipap/__init__.py 64 | sed -i "s/\(__db_version__\s*= \)[0-9]\+/\1$(DB_VER)/" nipap/__init__.py 65 | # update debian/changelog 66 | ../utilities/news2dch.py ../NEWS debian/changelog 67 | 68 | sql2py: 69 | echo '""" This file contains the nipap postgres db schemas.' > nipap/db_schema.py 70 | echo ' DO NOT EDIT THIS FILE. It is generated from sql/*.plsql files.' >> nipap/db_schema.py 71 | echo " Use 'make sql2py' to update" >> nipap/db_schema.py 72 | echo '"""' >> nipap/db_schema.py 73 | echo '' >> nipap/db_schema.py 74 | echo 'functions = """' >> nipap/db_schema.py 75 | cat sql/functions.plsql >> nipap/db_schema.py 76 | echo '"""' >> nipap/db_schema.py 77 | echo '' >> nipap/db_schema.py 78 | echo 'ip_net = """' >> nipap/db_schema.py 79 | cat sql/ip_net.plsql >> nipap/db_schema.py 80 | echo '"""' >> nipap/db_schema.py 81 | echo '' >> nipap/db_schema.py 82 | echo 'triggers = """' >> nipap/db_schema.py 83 | cat sql/triggers.plsql >> nipap/db_schema.py 84 | echo '"""' >> nipap/db_schema.py 85 | echo '' >> nipap/db_schema.py 86 | echo 'upgrade = [' >> nipap/db_schema.py 87 | for U in `ls sql/upgrade*.plsql | sort -n`; do \ 88 | echo '"""' >> nipap/db_schema.py; \ 89 | cat $$U >> nipap/db_schema.py; \ 90 | echo '""",' >> nipap/db_schema.py; \ 91 | done 92 | echo ']' >> nipap/db_schema.py 93 | -------------------------------------------------------------------------------- /nipap/README.rst: -------------------------------------------------------------------------------- 1 | NIPAP - Neat IP Address Planner 2 | =============================== 3 | NIPAP is a system built for managing large amounts of IP addresses built as an 4 | XML-RPC service. 5 | -------------------------------------------------------------------------------- /nipap/debian/control: -------------------------------------------------------------------------------- 1 | Source: nipap 2 | Maintainer: Lukas Garberg 3 | Section: python 4 | Priority: optional 5 | Build-Depends: debhelper-compat (= 13), 6 | dh-python, 7 | python3-all, 8 | python3-setuptools 9 | Standards-Version: 4.6.1 10 | Homepage: https://spritelink.github.io/NIPAP/ 11 | Rules-Requires-Root: no 12 | 13 | Package: nipap-common 14 | Architecture: all 15 | Multi-Arch: foreign 16 | Depends: ${misc:Depends}, ${python3:Depends} 17 | Suggests: python3-ldap 18 | Description: Neat IP Address Planner 19 | The Neat IP Address Planner, NIPAP, is a system built for efficiently managing 20 | large amounts of IP addresses. This is the common libraries. 21 | 22 | Package: nipapd 23 | Architecture: all 24 | Multi-Arch: foreign 25 | Depends: ${misc:Depends}, ${python3:Depends}, nipap-common 26 | Description: Neat IP Address Planner XML-RPC daemon 27 | The Neat IP Address Planner, NIPAP, is a system built for efficiently managing 28 | large amounts of IP addresses. This is the XML-RPC daemon. 29 | -------------------------------------------------------------------------------- /nipap/debian/copyright: -------------------------------------------------------------------------------- 1 | Package created by Lukas Garberg (lukagarb) 2 | on Fri, 7 Oct 2011 14:47:00 +0200. 3 | 4 | Upstream Author: 5 | 6 | Kristian Larsson (kll) 7 | Lukas Garberg (lukagarb) 8 | 9 | Files: * 10 | Copyright: 11 | 2011, Tele2 AB 12 | License: MIT 13 | 14 | License: MIT 15 | Copyright (C) 2011 by Kristian Larsson, Lukas Garberg 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /nipap/debian/nipap-common.install: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # the nipapd package is not unpacked at this stage, so this script needs to 4 | # know about the current version of the database 5 | CURRENT_DB_VERSION=7 6 | 7 | # to debug / develop 8 | # export DEBCONF_DEBUG=developer 9 | # export DEBIAN_PRIORITY=low 10 | # 11 | # to empty all answered questions from debconf db: 12 | # if the script is run standalone, stuff ends up in package "unknown" 13 | # echo PURGE | debconf-communicate unknown 14 | # if it's properly run from dpkg-configure or so, it should up under the package name 15 | # echo PURGE | debconf-communicate nipapd 16 | 17 | # Source debconf library. 18 | . /usr/share/debconf/confmodule 19 | 20 | POSTGRES_INSTALLED=0 21 | POSTGRES_RUNNING=0 22 | NIPAP_DB_EXISTS=0 23 | NIPAP_DB_VERSION=0 24 | 25 | # determine if postgres is installed 26 | su postgres -c 'psql --version' > /dev/null 2>&1 27 | if [ $? -eq 0 ]; then 28 | POSTGRES_INSTALLED=1 29 | 30 | su postgres -c "psql -c '\l+'" >/dev/null 2>&1 31 | if [ $? -eq 0 ]; then 32 | POSTGRES_RUNNING=1 33 | # does the NIPAP database exist? 34 | if [ "`su postgres -c "psql -c '\l+'" | awk -F"|" '{ if ($1~/^ *nipap *$/) { gsub(/^ */, "", $1); gsub(/ *$/, "", $1); print $1 } }'`" = "nipap" ]; then 35 | NIPAP_DB_EXISTS=1 36 | 37 | # figure out version of db 38 | DB_COMMENT=`su postgres -c "psql -c '\l+'" | awk -F"|" '{ if ($1~/^ *nipap *$/) { print $9 } }'` 39 | echo "$DB_COMMENT" | grep "schema version: [0-9]\+$" > /dev/null 2>&1 40 | if [ $? -eq 0 ]; then 41 | # seems to be a DB comment with proper version 42 | NIPAP_DB_VERSION=`echo $DB_COMMENT | sed 's/.*schema version: //'` 43 | fi 44 | fi 45 | fi 46 | fi 47 | 48 | # ask where the database is running 49 | db_input high nipapd/database_host || true 50 | db_go 51 | 52 | # automatically install db schema? 53 | db_get nipapd/database_host 54 | if [ "$RET" = "localhost" ]; then 55 | # It would be really weird if PostgreSQL wasn't installed 56 | if [ $POSTGRES_INSTALLED -eq 0 ]; then 57 | db_input high nipapd/local_db_not_installed || true 58 | db_go 59 | exit 60 | fi 61 | 62 | # It is not uncommon that PostgreSQL has been stopped as part of package 63 | # upgrades and if nipapd is in the same batch (again rather likely) we wouldn't 64 | # see PostgreSQL running by the time this script is executed. 65 | if [ $POSTGRES_RUNNING -eq 0 ]; then 66 | db_input high nipapd/local_db_not_running || true 67 | db_go 68 | exit 69 | fi 70 | 71 | # does user want automatic conf of db? 72 | db_input high nipapd/local_db_autoconf || true 73 | db_go 74 | 75 | # does user want automatic db schema upgrades? 76 | db_input high nipapd/local_db_upgrade || true 77 | db_go 78 | else 79 | # should we automatically install db schema? 80 | db_input high nipapd/remote_db_install || true 81 | db_go 82 | 83 | # should we automatically upgrade db schema? 84 | db_input high nipapd/remote_db_upgrade || true 85 | db_go 86 | fi 87 | 88 | 89 | # SQlite upgrade? 90 | if [ -n "`which nipap-passwd`" ]; then 91 | nipap-passwd latest-version 2>&1 >/dev/null 92 | if [ $? -eq 2 ]; then 93 | # TODO: not good to do db_reset here, it means we cannot configure this 94 | # package using debconf-communicate.. where can we put it instead? 95 | db_reset nipapd/sqlite_upgrade 96 | db_input high nipapd/sqlite_upgrade || true 97 | db_go 98 | fi 99 | fi 100 | 101 | # should nipapd be started on system boot? 102 | db_input high nipapd/startup || true 103 | db_go 104 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.default: -------------------------------------------------------------------------------- 1 | # defaults file for nipapd 2 | 3 | RUN=no 4 | AUTO_INSTALL=no 5 | AUTO_UPGRADE=no 6 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ### BEGIN INIT INFO 6 | # Provides: nipapd 7 | # Required-Start: $remote_fs $network postgresql 8 | # Required-Stop: $remote_fs $network postgresql 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: NIPAP XML-RPC server 12 | ### END INIT INFO 13 | 14 | DAEMON=/usr/bin/nipapd 15 | CONFIGFILE=/etc/nipap/nipap.conf 16 | NAME=NIPAPd 17 | PIDFILE=/var/run/nipap/nipapd.pid 18 | PIDDIR=`dirname $PIDFILE` 19 | 20 | . /lib/lsb/init-functions 21 | 22 | RUN=no 23 | # include defaults if available 24 | if [ -f /etc/default/nipapd ]; then 25 | . /etc/default/nipapd 26 | fi 27 | 28 | if [ "$RUN" != "yes" ]; then 29 | log_action_msg "$NAME disabled; edit /etc/default/nipapd" 30 | exit 0 31 | fi 32 | 33 | ARGS="" 34 | if [ "$AUTO_INSTALL" = "yes" ]; then 35 | ARGS="$ARGS --auto-install-db " 36 | fi 37 | 38 | if [ "$AUTO_UPGRADE" = "yes" ]; then 39 | ARGS="$ARGS --auto-upgrade-db " 40 | fi 41 | 42 | running() { 43 | # create dir for PID file if it doesn't exist 44 | if [ ! -d "$PIDDIR" ]; then 45 | mkdir "$PIDDIR" 46 | chown nipap:nipap $PIDDIR 47 | fi 48 | 49 | if [ $(flock -xn $PIDFILE -c 'echo 1' 2> /dev/null) ]; then 50 | echo -n 51 | rm -f $PIDFILE > /dev/null 2>&1 52 | else 53 | cat $PIDFILE || echo -n 54 | fi 55 | } 56 | 57 | 58 | case "$1" in 59 | start) 60 | log_daemon_msg "Starting NIPAPd XML-RPC server" "nipapd" 61 | RUNNING=$(running) 62 | if [ -n "$RUNNING" ]; then 63 | log_progress_msg "already running" 64 | log_end_msg 0 65 | else 66 | if start-stop-daemon --start --exec $DAEMON -- -c $CONFIGFILE $ARGS; then 67 | log_end_msg 0 68 | else 69 | log_end_msg 1 70 | fi 71 | fi 72 | ;; 73 | stop) 74 | log_daemon_msg "Stopping NIPAPd XML-RPC server" "nipapd" 75 | RUNNING=$(running) 76 | if [ -n "$RUNNING" ]; then 77 | if start-stop-daemon --stop --pidfile $PIDFILE --retry 30; then 78 | log_end_msg 0 79 | else 80 | log_end_msg 1 81 | fi 82 | else 83 | log_end_msg 0 84 | fi 85 | ;; 86 | reload) 87 | log_daemon_msg "Reloading NIPAPd XML-RPC server's configuration" "nipapd" 88 | RUNNING=$(running) 89 | if [ -n "$RUNNING" ]; then 90 | if start-stop-daemon --stop --signal HUP --pidfile $PIDFILE; then 91 | log_end_msg 0 92 | else 93 | log_end_msg 1 94 | fi 95 | else 96 | log_failure_msg "NIPAPd XML-RPC server not running" 97 | fi 98 | ;; 99 | force-reload) 100 | $0 reload 101 | ;; 102 | restart) 103 | log_daemon_msg "Restarting NIPAPd XML-RPC server" "nipapd" 104 | RUNNING=$(running) 105 | if [ -n "$RUNNING" ]; then 106 | if start-stop-daemon --stop --pidfile $PIDFILE; then 107 | if start-stop-daemon --start --exec $DAEMON -- -c $CONFIGFILE $ARGS; then 108 | log_end_msg 0 109 | else 110 | log_end_msg 1 111 | fi 112 | else 113 | log_end_msg 1 114 | fi 115 | else 116 | if start-stop-daemon --start --exec $DAEMON -- -c $CONFIGFILE $ARGS; then 117 | log_end_msg 0 118 | else 119 | log_end_msg 1 120 | fi 121 | fi 122 | ;; 123 | status) 124 | RUNNING=$(running) 125 | if [ -n "$RUNNING" ]; then 126 | log_success_msg "NIPAPd XML-RPC server running with PID $RUNNING" 127 | exit 0 128 | else 129 | log_failure_msg "NIPAPd XML-RPC not running" 130 | exit 3 131 | fi 132 | ;; 133 | *) 134 | log_action_msg "Usage: /etc/init.d/nipapd {start|stop|restart|reload|force-reload|status}" 135 | esac 136 | 137 | exit 0 138 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.install: -------------------------------------------------------------------------------- 1 | usr/bin/nipapd 2 | usr/bin/nipap-passwd 3 | usr/share/nipap 4 | usr/share/nipap/nipap.conf.dist etc/nipap 5 | usr/share/man/man8/nipapd.8 6 | usr/share/man/man1/nipap-passwd.1 7 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.manpages: -------------------------------------------------------------------------------- 1 | nipap-passwd.1 2 | nipapd.8 3 | -------------------------------------------------------------------------------- /nipap/debian/nipapd.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "purge" ] ; then 4 | # clean up rc.d 5 | update-rc.d nipapd remove >/dev/null 6 | 7 | # remove nipap user and group 8 | deluser nipap > /dev/null 2>&1 9 | delgroup nipap > /dev/null 2>&1 10 | 11 | if [ -e /usr/share/debconf/confmodule ]; then 12 | # Source debconf library. 13 | . /usr/share/debconf/confmodule 14 | # Remove my changes to the db. 15 | db_purge 16 | fi 17 | 18 | exit 0 19 | fi 20 | -------------------------------------------------------------------------------- /nipap/debian/py3dist-overrides: -------------------------------------------------------------------------------- 1 | flask-restx python3-flask-restx 2 | Flask python3-flask (>= 2.0.0) 3 | flask-xml-rpc-re python3-flask-xml-rpc-re 4 | -------------------------------------------------------------------------------- /nipap/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # This file was automatically generated by stdeb 0.6.0+git at 4 | # Tue, 18 Oct 2011 21:55:07 +0200 5 | export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ --with python3 --buildsystem=pybuild 9 | -------------------------------------------------------------------------------- /nipap/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /nipap/debian/source/options: -------------------------------------------------------------------------------- 1 | # Don't store "changes" made to Makefile and some other files 2 | extend-diff-ignore = "(^|/)(entrypoint.sh|Makefile|xmlbench.py|xml-test.py|MANIFEST|nipapd.man.rst|nipap-passwd.man.rst|clean.plsql|requirements.txt|wait-for-it.sh)$" 3 | -------------------------------------------------------------------------------- /nipap/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir -p /etc/nipap/ 4 | envtpl --allow-missing --keep-template /usr/local/share/nipap/nipap.conf.dist -o /etc/nipap/nipap.conf 5 | /bin/bash /nipap/wait-for-it.sh -t 60 $DB_HOST:$DB_PORT -- sleep 5 6 | 7 | /usr/local/bin/nipap-passwd create-database 8 | if [ -n "$NIPAP_USERNAME" -a -n "$NIPAP_PASSWORD" ]; then 9 | echo "Creating user '$NIPAP_USERNAME'" 10 | /usr/local/bin/nipap-passwd add --username $NIPAP_USERNAME --name "NIPAP user" --password $NIPAP_PASSWORD 11 | fi 12 | echo "Starting nipap daemon.." 13 | exec /usr/local/bin/nipapd --debug --foreground --auto-install-db --auto-upgrade-db --no-pid-file 14 | -------------------------------------------------------------------------------- /nipap/nipap/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.32.7" 2 | __db_version__ = 7 3 | __author__ = "Kristian Larsson, Lukas Garberg" 4 | __author_email__ = "kll@tele2.net, lukas@spritelink.net" 5 | __copyright__ = "Copyright 2011-2014, Kristian Larsson, Lukas Garberg" 6 | __license__ = "MIT" 7 | __status__ = "Development" 8 | __url__ = "http://SpriteLink.github.io/NIPAP" 9 | -------------------------------------------------------------------------------- /nipap/nipap/errors.py: -------------------------------------------------------------------------------- 1 | class NipapError(Exception): 2 | """ NIPAP base error class. 3 | """ 4 | 5 | error_code = 1000 6 | 7 | 8 | class NipapInputError(NipapError): 9 | """ Erroneous input. 10 | 11 | A general input error. 12 | """ 13 | 14 | error_code = 1100 15 | 16 | 17 | class NipapMissingInputError(NipapInputError): 18 | """ Missing input. 19 | 20 | Most input is passed in dicts, this could mean a missing key in a dict. 21 | """ 22 | 23 | error_code = 1110 24 | 25 | 26 | class NipapExtraneousInputError(NipapInputError): 27 | """ Extraneous input. 28 | 29 | Most input is passed in dicts, this could mean an unknown key in a dict. 30 | """ 31 | 32 | error_code = 1120 33 | 34 | 35 | class NipapNoSuchOperatorError(NipapInputError): 36 | """ A non existent operator was specified. 37 | """ 38 | 39 | error_code = 1130 40 | 41 | 42 | class NipapValueError(NipapError): 43 | """ Something wrong with a value 44 | 45 | For example, trying to send an integer when an IP address is expected. 46 | """ 47 | 48 | error_code = 1200 49 | 50 | 51 | class NipapNonExistentError(NipapError): 52 | """ A non existent object was specified 53 | 54 | For example, try to get a prefix from a pool which doesn't exist. 55 | """ 56 | 57 | error_code = 1300 58 | 59 | 60 | class NipapDuplicateError(NipapError): 61 | """ The passed object violates unique constraints 62 | 63 | For example, create a VRF with a name of an already existing one. 64 | """ 65 | 66 | error_code = 1400 67 | 68 | 69 | class NipapDatabaseError(NipapError): 70 | """ Database related errors 71 | """ 72 | 73 | 74 | class NipapDatabaseNonExistentError(NipapDatabaseError): 75 | """ The nipap database does not exist 76 | """ 77 | 78 | 79 | class NipapDatabaseSchemaError(NipapDatabaseError): 80 | """ Something wrong withe the database schema 81 | """ 82 | 83 | 84 | class NipapDatabaseNoVersionError(NipapDatabaseSchemaError): 85 | """ The nipap database schema version number is missing 86 | 87 | This is assumed to mean the database is empty 88 | """ 89 | 90 | 91 | class NipapDatabaseWrongVersionError(NipapDatabaseSchemaError): 92 | """ The nipap database schema is of the wrong version 93 | """ 94 | 95 | 96 | class NipapDatabaseMissingExtensionError(NipapDatabaseSchemaError): 97 | """ The nipap database is missing an extension 98 | """ 99 | -------------------------------------------------------------------------------- /nipap/nipap/nipapconfig.py: -------------------------------------------------------------------------------- 1 | import configparser 2 | 3 | DEFAULT = { 4 | 'syslog': 'false', 5 | 'debug': 'false', 6 | 'foreground': 'false', 7 | 'forks': 0, 8 | 'pid_file': '', 9 | 'listen': '127.0.0.1', 10 | 'port': '1337', 11 | 'ssl_port': '', 12 | 'ssl_cert_file': '', 13 | 'ssl_key_file': '', 14 | 'db_host': 'localhost', 15 | 'db_name': 'nipap', 16 | 'db_port': '', 17 | 'db_user': 'nipap', 18 | 'db_pass': 'papin', 19 | 'db_sslmode': 'require', 20 | 'auth_cache_timeout': '3600', 21 | 'user': '', 22 | 'group': '' 23 | } 24 | 25 | 26 | 27 | class NipapConfig(configparser.ConfigParser): 28 | """ Makes configuration data available. 29 | 30 | Implemented as a class with a shared state; once an instance has been 31 | created, new instances with the same state can be obtained by calling 32 | the constructor again. 33 | """ 34 | 35 | __shared_state = {} 36 | _config = None 37 | _cfg_path = None 38 | 39 | def __init__(self, cfg_path=None): 40 | """ Takes config file path and command line arguments. 41 | """ 42 | 43 | self.__dict__ = self.__shared_state 44 | 45 | if len(self.__shared_state) == 0: 46 | # First time - create new instance! 47 | self._cfg_path = cfg_path 48 | 49 | configparser.ConfigParser.__init__(self, DEFAULT, inline_comment_prefixes=";#") 50 | 51 | self.read_config_file() 52 | 53 | def read_config_file(self): 54 | """ Read the configuration file 55 | """ 56 | 57 | # don't try to parse config file if we don't have one set 58 | if not self._cfg_path: 59 | return 60 | 61 | try: 62 | cfg_fp = open(self._cfg_path, 'r') 63 | self.read_file(cfg_fp) 64 | except IOError as exc: 65 | raise NipapConfigError(str(exc)) 66 | 67 | 68 | class NipapConfigError(Exception): 69 | pass 70 | -------------------------------------------------------------------------------- /nipap/nipapd.man.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | nipapd 3 | ====== 4 | 5 | the NIPAP backend server 6 | ======================== 7 | 8 | Synopsis 9 | -------- 10 | **nipapd** [option...] 11 | 12 | Description 13 | ----------- 14 | **nipapd** is the NIPAP backend server. In order for a client application to access information stored in the NIPAP database, it connects (over a network or locally) to a running nipapd backend instance and sends its' requests. 15 | 16 | By default nipapd will fork off into the background and listen to TCP port 1337 for requests from clients. 17 | 18 | Options 19 | ------- 20 | nipapd accepts the following command-line arguments. These and more options are available in the configuration file nipap.conf, which typically resides in /etc/nipap/nipap.conf. On debian-like systems, /etc/default/nipapd is used to control the startup of nipapd in the init script. 21 | 22 | -h, --help show a help message 23 | -d, --debug enable debugging 24 | -f, --foreground run in foreground and log to stdout 25 | -l ADDRESS, --listen=ADDRESS listen to IPv4/6 **ADDRESS** 26 | -p PORT, --port=PORT listen on TCP port **PORT** 27 | -c CONFIG-FILE, --config=CONFIG_FILE read configuration from file **CONFIG_FILE** 28 | -P PID_FILE, --pid-file=PID_FILE write a PID file to **PID_FILE** 29 | --no-pid-file turn off writing a PID file (overrides config file) 30 | --version display version information and exit 31 | 32 | Bugs / Caveats 33 | -------------- 34 | Who knows? ;) 35 | 36 | Examples 37 | -------- 38 | To start nipapd in the background using default values, type: 39 | $ nipapd 40 | 41 | To start nipapd in the foreground with debug logging, running on a specific port, e.g. 1234 and with no PID file, typically for development: 42 | $ nipapd -d -f -p 1234 --no-pid-file 43 | 44 | Copyright 45 | --------- 46 | Kristian Larsson, Lukas Garberg 2011-2014 47 | -------------------------------------------------------------------------------- /nipap/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "nipap" 3 | dynamic = ["version", "description"] 4 | readme = "README.rst" 5 | license = {text = "MIT"} 6 | classifiers = [ 7 | 'Development Status :: 4 - Beta', 8 | 'Intended Audience :: Developers', 9 | 'Intended Audience :: System Administrators', 10 | 'License :: OSI Approved :: MIT License', 11 | 'Natural Language :: English', 12 | 'Operating System :: POSIX :: Linux', 13 | 'Programming Language :: Python :: 3' 14 | ] 15 | keywords = ["nipap"] 16 | dependencies = [ 17 | "zipp==3.21.0", 18 | "importlib_metadata==8.5.0", 19 | "Flask==3.0.3", 20 | "Flask-Compress==1.17", 21 | "flask-xml-rpc-re==0.1.4", 22 | "flask-restx==1.3.0", 23 | "requests==2.32.3", 24 | "IPy==1.01", 25 | "Jinja2==3.1.5", 26 | "MarkupSafe==3.0.2", 27 | "Werkzeug==3.1.3", 28 | "certifi==2024.12.14", 29 | "itsdangerous==2.2.0", 30 | "parsedatetime==2.6", 31 | "psutil==6.1.1", 32 | "psycopg2==2.9.10", 33 | "pyparsing==3.2.1", 34 | "python-dateutil==2.8.2", 35 | "pytz==2024.2", 36 | "pyjwt==2.10.1", 37 | "tornado==6.4.2", 38 | # "docutils==0.21.2" 39 | ] 40 | 41 | [project.optional-dependencies] 42 | instrumentation = [ 43 | "opentelemetry-api==1.29.0", 44 | "opentelemetry-exporter-otlp==1.29.0", 45 | "opentelemetry-exporter-otlp-proto-common==1.29.0", 46 | "opentelemetry-exporter-otlp-proto-grpc==1.29.0", 47 | "opentelemetry-exporter-otlp-proto-http==1.29.0", 48 | "opentelemetry-instrumentation==0.50b0", 49 | "opentelemetry-instrumentation-dbapi==0.50b0", 50 | "opentelemetry-instrumentation-flask==0.50b0", 51 | "opentelemetry-instrumentation-psycopg2==0.50b0", 52 | "opentelemetry-instrumentation-wsgi==0.50b0", 53 | "opentelemetry-proto==1.29.0", 54 | "opentelemetry-sdk==1.29.0", 55 | "opentelemetry-semantic-conventions==0.50b0", 56 | "opentelemetry-util-http==0.50b0" 57 | ] 58 | 59 | ldap_auth = [ 60 | "python-ldap==3.4.4" 61 | ] 62 | 63 | [project.urls] 64 | Homepage = "http://SpriteLink.github.io/NIPAP" 65 | 66 | [project.scripts] 67 | nipapd = "nipap.nipapd:run" 68 | nipap-passwd = "nipap.nipap_passwd:run" 69 | 70 | [tool.setuptools.dynamic] 71 | version = {attr = "nipap.__version__"} 72 | 73 | [build-system] 74 | requires = [ 75 | "setuptools", 76 | # Need to be pinned to 0.20.1 in Ubuntu 24.04 as using the latest 0.21.2 77 | # gives a diff during .deb package build. Unfortunately the files are 78 | # generated twice - first once in a virtualenv (using the version specified 79 | # here) and then once without a virtualenv using the one from the system. 80 | # There two runs produce different outputs (wich they shouldn't) causing a 81 | # diff and the package utils to b0rk out. 82 | "docutils==0.20.1" 83 | ] 84 | build-backend = "setuptools.build_meta" 85 | -------------------------------------------------------------------------------- /nipap/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from setuptools import setup 4 | from docutils.core import publish_cmdline 5 | from docutils.writers import manpage 6 | import sys 7 | import re 8 | 9 | 10 | # return all the extra data files 11 | def get_data_files(): 12 | # generate man pages using rst2man 13 | try: 14 | publish_cmdline(writer=manpage.Writer(), argv=["nipapd.man.rst", "nipapd.8"]) 15 | publish_cmdline(writer=manpage.Writer(), argv=["nipap-passwd.man.rst", "nipap-passwd.1"]) 16 | except OSError as exc: 17 | print("rst2man failed to run: %s" % str(exc), file=sys.stderr) 18 | sys.exit(1) 19 | 20 | files = [ 21 | ('share/nipap/', ['nipap.conf.dist']), 22 | ('share/nipap/sql/', [ 23 | 'sql/upgrade-1-2.plsql', 24 | 'sql/upgrade-2-3.plsql', 25 | 'sql/upgrade-3-4.plsql', 26 | 'sql/upgrade-4-5.plsql', 27 | 'sql/upgrade-5-6.plsql', 28 | 'sql/upgrade-6-7.plsql', 29 | 'sql/functions.plsql', 30 | 'sql/triggers.plsql', 31 | 'sql/ip_net.plsql', 32 | ], 33 | ), 34 | ('share/man/man8/', ['nipapd.8']), 35 | ('share/man/man1/', ['nipap-passwd.1']), 36 | ] 37 | 38 | return files 39 | 40 | 41 | long_desc = open('README.rst').read() 42 | short_desc = long_desc.split('\n')[0].split(' - ')[1].strip() 43 | 44 | setup( 45 | description=short_desc, 46 | long_description=long_desc, 47 | packages=['nipap'], 48 | keywords=['nipap'], 49 | data_files=get_data_files(), 50 | ) 51 | -------------------------------------------------------------------------------- /nipap/sql/Makefile: -------------------------------------------------------------------------------- 1 | #.PHONY: install auth db tables clean clean-db clean-tables 2 | # vim: ts=8 : 3 | 4 | PSQL=psql 5 | 6 | DB_NAME=nipap 7 | DB_USER=nipap 8 | # PGPASSWORD is the standard environment variable used by the PostgreSQL cli 9 | # application to pass a password as it does not accept passwords via any 10 | # arguments. If PGPASSWORD is set then we use that for the password of our new 11 | # user. Otherwise we default to generating a new random password.c 12 | ifndef PGPASSWORD 13 | PG_PASS_RAND=1 14 | DB_PASS:=$(shell 2 | nso-nipap 3 | 1.0 4 | Client library for communcation with a NIPAP backend 5 | 3.0 6 | 7 | 8 | nsoNipap 9 | 10 | net.spritelink.nsonipap.nsoNipap 11 | 12 | 13 | 14 | 15 | Reactive FM CDB Config Subscriber 16 | 17 | net.spritelink.nsonipap.ConfigCdbSub 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/private-jar/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/shared-jar/commons-logging-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nso-nipap/nso-nipap/shared-jar/commons-logging-1.1.jar -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/shared-jar/ws-commons-util-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nso-nipap/nso-nipap/shared-jar/ws-commons-util-1.0.2.jar -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/shared-jar/xmlrpc-client-3.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nso-nipap/nso-nipap/shared-jar/xmlrpc-client-3.1.3.jar -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/shared-jar/xmlrpc-common-3.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/nso-nipap/nso-nipap/shared-jar/xmlrpc-common-3.1.3.jar -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/src/Makefile: -------------------------------------------------------------------------------- 1 | 2 | JAVA_PACKAGE = net.spritelink.nsonipap 3 | JDIR = $(shell echo $(JAVA_PACKAGE) | sed 's/\./\//g') 4 | 5 | NS = namespaces 6 | 7 | JFLAGS = --java-disable-prefix \ 8 | --exclude-enums \ 9 | --fail-on-warnings \ 10 | --java-package $(JAVA_PACKAGE).$(NS) \ 11 | --emit-java java/src/$(JDIR)/namespaces 12 | 13 | all: fxs javac 14 | 15 | # Include standard NCS examples build definitions and rules 16 | include $(NCS_DIR)/src/ncs/build/include.ncs.mk 17 | 18 | SRC = $(wildcard yang/*.yang) 19 | FXS = $(SRC:yang/%.yang=../load-dir/%.fxs) 20 | 21 | fxs: $(FXS) 22 | 23 | ../load-dir/%.fxs: yang/%.yang 24 | $(NCSC) `ls $*-ann.yang > /dev/null 2>&1 && echo "-a $*-ann.yang"` \ 25 | $(YANGPATH) -c -o $@ $< 26 | $(NCSC) $(JFLAGS)/$*.java $@ 27 | 28 | javac: 29 | cd java && ant -q all 30 | 31 | clean: 32 | rm -rf ../load-dir/* 33 | rm -f ../private-jar/*.jar 34 | cd java && ant -q clean || true 35 | rm -f java/src/$(JDIR)/$(NS)/*.java 36 | -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/src/java/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /nso-nipap/nso-nipap/src/java/src/net/spritelink/nsonipap/namespaces/.gitignore: -------------------------------------------------------------------------------- 1 | *.java 2 | -------------------------------------------------------------------------------- /ojnipap/Makefile: -------------------------------------------------------------------------------- 1 | DEP = -classpath .:../jnipap/jnipap.jar:./lib/ojdbc5.jar 2 | JFLAGS = -g -Xlint $(DEP) 3 | JC = javac 4 | JAR = jar 5 | JARFILE = ojnipap.jar 6 | JARFLAGS = cf $(JARFILE) 7 | 8 | default: classes 9 | 10 | jnipap: 11 | cd ../jnipap && make jar 12 | 13 | classes: jnipap 14 | $(JC) $(JFLAGS) -source 1.4 ojnipap/*.java 15 | 16 | jar: classes 17 | $(JAR) $(JARFLAGS) ojnipap/*.class 18 | 19 | clean: 20 | $(RM) *.class ojnipap/*.class $(JARFILE) 21 | -------------------------------------------------------------------------------- /ojnipap/README.rst: -------------------------------------------------------------------------------- 1 | OJNIPAP - a NIPAP client library in for Oracle database 2 | ======================================================= 3 | OJNIPAP is a client library used to communicate with the NIPAP XML-RPC service 4 | from Oracle Database. It consists of classes using the SQLObject API to 5 | facilitate passing of NIPAP objects between the SQL and Java world as well as, 6 | somewhat limited, access to the NIPAP API functions. 7 | 8 | Currently the SQL definitions needed to access the NIPAP functions from the 9 | database is missing, but will be added. 10 | 11 | Build instructions 12 | ------------------ 13 | OJNIPAP depends on JNIPAP and the Oracle Database JDBC drivers. JNIPAP will 14 | automatically be built when needed, but the JDBC drivers must be downloaded 15 | from Oracle. Place the file ``ojdbc5.jar`` in the ojnipap/lib directory and 16 | then build OJNIPAP with: 17 | 18 | ``make jar``` 19 | -------------------------------------------------------------------------------- /ojnipap/lib/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory, except this file 2 | * 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/Helpers.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import java.sql.SQLInput; 6 | import java.sql.SQLException; 7 | 8 | class Helpers { 9 | 10 | /** 11 | * Take string and return Oracle-friendly value 12 | * 13 | * As Oracle handles empty strings as null, it seems as empty strings needs 14 | * to be converted to null before sent to writeString. 15 | * 16 | * @param str Input string 17 | * @return String or null 18 | */ 19 | static String strOrNull(String str) { 20 | 21 | if (str == null) { 22 | return str; 23 | } 24 | 25 | if (str.length() == 0) { 26 | return null; 27 | } else { 28 | return str; 29 | } 30 | 31 | } 32 | 33 | /** 34 | * Convert Boolean to BigDecimal 35 | * 36 | * As Oracle lacks a boolean type, they have in ojnipap been implemented as 37 | * the type NUMBER(1). This function handles conversion from boolean to 38 | * BigDecimal; if the input boolean is true the function returns a 39 | * BigDecimal with the value 1, otherwise 0. 40 | * 41 | * @param b Boolean value 42 | * @return A BigDecimal with values 0 or 1 43 | */ 44 | static BigDecimal bigDecBoolOrNull(Boolean b) { 45 | 46 | if (b == null) { 47 | return null; 48 | } 49 | 50 | return new BigDecimal(b.booleanValue() ? 1 : 0); 51 | 52 | } 53 | 54 | /** 55 | * Take Integer and return Oracle-friendly value 56 | * 57 | * This function returns either a BigDecimal suitable for the 58 | * writeBigDecimal function, or null if the input value is null. 59 | * 60 | * @param i Input integer 61 | * @return BigDecimal with value of input integer, or null 62 | */ 63 | static BigDecimal bigDecOrNull(Integer i) { 64 | 65 | if (i == null) { 66 | return null; 67 | } 68 | 69 | return new BigDecimal(i.intValue()); 70 | 71 | } 72 | 73 | /** 74 | * Read BigDecimal value from stream and return Integer or null 75 | * 76 | * This helper function reads a BigDecimal from the stream. If the stream 77 | * contains a null value, null is returned. Otherwise an Integer object 78 | * with the requested value is returned. 79 | * 80 | * @param val stream to read data from 81 | * @return Integer object 82 | */ 83 | static Integer integerOrNull(BigDecimal val) throws SQLException { 84 | 85 | if (val == null) { 86 | return null; 87 | } 88 | 89 | return new Integer(val.intValue()); 90 | 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OAddPrefixOptions.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import java.sql.SQLData; 6 | import java.sql.SQLInput; 7 | import java.sql.SQLOutput; 8 | import java.sql.SQLException; 9 | 10 | import jnipap.AddPrefixOptions; 11 | 12 | /** 13 | * SQLObject mapped AddPrefixOptions class 14 | */ 15 | public class OAddPrefixOptions extends AddPrefixOptions implements SQLData { 16 | 17 | // version ID for serialization 18 | private static final long serialVersionUID = 0L; 19 | 20 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 21 | 22 | // Read data 23 | BigDecimal family = stream.readBigDecimal(); 24 | BigDecimal prefLength = stream.readBigDecimal(); 25 | 26 | // Add the keys which have a non-null value 27 | if (family != null) { 28 | put("family", new Integer(family.intValue())); 29 | } 30 | if (prefLength != null) { 31 | put("prefix_length", new Integer(prefLength.intValue())); 32 | } 33 | 34 | } 35 | 36 | public void writeSQL(SQLOutput stream) throws SQLException { 37 | 38 | Integer family; 39 | 40 | // Write values to stream if defined, otherwise write null. 41 | if (containsKey("family")) { 42 | stream.writeBigDecimal(new BigDecimal(((Integer)get("family")).intValue())); 43 | } else { 44 | stream.writeBigDecimal(null); 45 | } 46 | if (containsKey("prefix_length")) { 47 | stream.writeBigDecimal(new BigDecimal(((Integer)get("prefix_length")).intValue())); 48 | } else { 49 | stream.writeBigDecimal(null); 50 | } 51 | 52 | } 53 | 54 | public String getSQLTypeName() { 55 | 56 | return "NIPAP_ADD_PREFIX_OPTIONS"; 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OConnection.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.net.URL; 4 | 5 | import java.sql.SQLData; 6 | import java.sql.SQLInput; 7 | import java.sql.SQLOutput; 8 | import java.sql.SQLException; 9 | import java.net.MalformedURLException; 10 | 11 | import jnipap.Connection; 12 | 13 | /** 14 | * SQLObject version of the Connection class 15 | */ 16 | public class OConnection extends jnipap.Connection implements SQLData { 17 | 18 | private static final long serialVersionUID = 0; 19 | 20 | /** 21 | * Create instance from SQL. 22 | */ 23 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 24 | 25 | try { 26 | srv_url = new URL(stream.readString()); 27 | } catch(MalformedURLException e) { 28 | throw new SQLException(e); 29 | } 30 | 31 | full_name = stream.readString(); 32 | authoritative_source = stream.readString(); 33 | auth_username = stream.readString(); 34 | username = stream.readString(); 35 | password = stream.readString(); 36 | 37 | setup(); 38 | 39 | } 40 | 41 | /** 42 | * Write data back to SQL. 43 | */ 44 | public void writeSQL(SQLOutput stream) throws SQLException { 45 | 46 | stream.writeString(srv_url.toString()); 47 | stream.writeString(full_name); 48 | stream.writeString(authoritative_source); 49 | stream.writeString(auth_username); 50 | stream.writeString(password); 51 | 52 | } 53 | 54 | /** 55 | * Get name of the corresponding SQL type. 56 | * 57 | * @return Name of type. 58 | */ 59 | public String getSQLTypeName() { 60 | return "NIPAP_CONNECTION"; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OPool.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import java.sql.SQLData; 6 | import java.sql.SQLInput; 7 | import java.sql.SQLOutput; 8 | import java.sql.SQLException; 9 | 10 | import oracle.sql.STRUCT; 11 | 12 | import jnipap.Pool; 13 | 14 | /** 15 | * SQLObject version of the Pool class 16 | */ 17 | public class OPool extends jnipap.Pool implements SQLData { 18 | 19 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 20 | 21 | // Read data from stream 22 | id = Helpers.integerOrNull(stream.readBigDecimal()); 23 | name = stream.readString(); 24 | description = stream.readString(); 25 | default_type = stream.readString(); 26 | ipv4_default_prefix_length = Helpers.integerOrNull(stream.readBigDecimal()); 27 | ipv6_default_prefix_length = Helpers.integerOrNull(stream.readBigDecimal()); 28 | vrf = OVRF.fromSTRUCT((STRUCT)stream.readObject()); 29 | 30 | } 31 | 32 | public void writeSQL(SQLOutput stream) throws SQLException { 33 | 34 | // Write data to stream 35 | stream.writeBigDecimal(Helpers.bigDecOrNull(id)); 36 | stream.writeString(Helpers.strOrNull(name)); 37 | stream.writeString(Helpers.strOrNull(description)); 38 | stream.writeString(Helpers.strOrNull(default_type)); 39 | stream.writeBigDecimal(Helpers.bigDecOrNull(ipv4_default_prefix_length)); 40 | stream.writeBigDecimal(Helpers.bigDecOrNull(ipv6_default_prefix_length)); 41 | stream.writeObject((OVRF)vrf); 42 | 43 | } 44 | 45 | public String getSQLTypeName() { 46 | 47 | return "NIPAP_POOL"; 48 | 49 | } 50 | 51 | /** 52 | * Create OPool object from oracle.sql.STRUCT 53 | * 54 | * @param input STRUCT object contaning a NIPAP_POOL Oracle object 55 | * @return An OPool instance 56 | */ 57 | static OPool fromSTRUCT(STRUCT input) throws SQLException { 58 | 59 | // If we received null, return a null pointer 60 | if (input == null) { 61 | return null; 62 | } 63 | 64 | // Create new OPool object from the STRUCT data 65 | OPool p = new OPool(); 66 | 67 | Object[] val = input.getAttributes(); 68 | p.id = Helpers.integerOrNull((BigDecimal)val[0]); 69 | p.name = (String)val[1]; 70 | p.description = (String)val[2]; 71 | p.default_type = (String)val[3]; 72 | p.ipv4_default_prefix_length = Helpers.integerOrNull((BigDecimal)val[4]); 73 | p.ipv6_default_prefix_length = Helpers.integerOrNull((BigDecimal)val[5]); 74 | p.vrf = (jnipap.VRF)OVRF.fromSTRUCT((STRUCT)val[6]); 75 | 76 | return p; 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OPrefix.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.sql.SQLData; 4 | import java.sql.SQLInput; 5 | import java.sql.SQLOutput; 6 | import java.sql.SQLException; 7 | 8 | import oracle.sql.STRUCT; 9 | 10 | import jnipap.Connection; 11 | import jnipap.VRF; 12 | import jnipap.Pool; 13 | import jnipap.Prefix; 14 | 15 | /** 16 | * SQLObject version of the Prefix class 17 | */ 18 | public class OPrefix extends jnipap.Prefix implements SQLData { 19 | 20 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 21 | 22 | // Read data from stream 23 | id = Helpers.integerOrNull(stream.readBigDecimal()); 24 | family = Helpers.integerOrNull(stream.readBigDecimal()); 25 | vrf = OVRF.fromSTRUCT((STRUCT)stream.readObject()); 26 | prefix = stream.readString(); 27 | display_prefix = stream.readString(); 28 | description = stream.readString(); 29 | comment = stream.readString(); 30 | node = stream.readString(); 31 | pool = OPool.fromSTRUCT((STRUCT)stream.readObject()); 32 | type = stream.readString(); 33 | indent = Helpers.integerOrNull(stream.readBigDecimal()); 34 | country = stream.readString(); 35 | order_id = stream.readString(); 36 | customer_id = stream.readString(); 37 | external_key = stream.readString(); 38 | authoritative_source = stream.readString(); 39 | alarm_priority = stream.readString(); 40 | monitor = new Boolean(stream.readBoolean()); 41 | 42 | // Skip display, match and children as these are "read-only" 43 | 44 | } 45 | 46 | public void writeSQL(SQLOutput stream) throws SQLException { 47 | 48 | // Write data to stream 49 | stream.writeBigDecimal(Helpers.bigDecOrNull(id)); 50 | stream.writeBigDecimal(Helpers.bigDecOrNull(family)); 51 | stream.writeObject((OVRF)vrf); 52 | stream.writeString(Helpers.strOrNull(prefix)); 53 | stream.writeString(Helpers.strOrNull(display_prefix)); 54 | stream.writeString(Helpers.strOrNull(description)); 55 | stream.writeString(Helpers.strOrNull(comment)); 56 | stream.writeString(Helpers.strOrNull(node)); 57 | stream.writeObject((OPool)pool); 58 | stream.writeString(Helpers.strOrNull(type)); 59 | stream.writeBigDecimal(Helpers.bigDecOrNull(indent)); 60 | stream.writeString(Helpers.strOrNull(country)); 61 | stream.writeString(Helpers.strOrNull(order_id)); 62 | stream.writeString(Helpers.strOrNull(customer_id)); 63 | stream.writeString(Helpers.strOrNull(external_key)); 64 | stream.writeString(Helpers.strOrNull(authoritative_source)); 65 | stream.writeString(Helpers.strOrNull(alarm_priority)); 66 | stream.writeBigDecimal(Helpers.bigDecBoolOrNull(monitor)); 67 | stream.writeBigDecimal(Helpers.bigDecBoolOrNull(display)); 68 | stream.writeBigDecimal(Helpers.bigDecBoolOrNull(match)); 69 | stream.writeBigDecimal(Helpers.bigDecOrNull(children)); 70 | 71 | } 72 | 73 | public String getSQLTypeName() { 74 | 75 | return "NIPAP_PREFIX"; 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OSearchOptions.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.util.HashMap; 4 | 5 | import java.sql.SQLData; 6 | import java.sql.SQLInput; 7 | import java.sql.SQLOutput; 8 | import java.sql.SQLException; 9 | 10 | public class OSearchOptions extends HashMap implements SQLData { 11 | 12 | // version ID for serialization 13 | private static final long serialVersionUID = 0L; 14 | 15 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 16 | 17 | put("max_result", new Integer(stream.readBigDecimal().intValue())); 18 | put("offset", new Integer(stream.readBigDecimal().intValue())); 19 | 20 | } 21 | 22 | public void writeSQL(SQLOutput stream) throws SQLException { 23 | 24 | stream.writeBigDecimal(Helpers.bigDecOrNull((Integer)get("max_result"))); 25 | stream.writeBigDecimal(Helpers.bigDecOrNull((Integer)get("offset"))); 26 | 27 | } 28 | 29 | public String getSQLTypeName() { 30 | 31 | return "NIPAP_SEARCH_OPTIONS"; 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /ojnipap/ojnipap/OVRF.java: -------------------------------------------------------------------------------- 1 | package ojnipap; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.HashMap; 6 | 7 | import java.math.BigDecimal; 8 | 9 | import java.sql.Array; 10 | import java.sql.SQLData; 11 | import java.sql.SQLInput; 12 | import java.sql.SQLOutput; 13 | import java.sql.SQLException; 14 | 15 | import oracle.sql.STRUCT; 16 | 17 | import jnipap.VRF; 18 | import jnipap.Pool; 19 | import jnipap.Prefix; 20 | import jnipap.Connection; 21 | import jnipap.JnipapException; 22 | import jnipap.Connection; 23 | 24 | import ojnipap.OConnection; 25 | 26 | /** 27 | * SQLObject version of the VRF class 28 | */ 29 | public class OVRF extends jnipap.VRF implements SQLData { 30 | 31 | public void readSQL(SQLInput stream, String typeName) throws SQLException { 32 | 33 | // Read data from stream 34 | id = Helpers.integerOrNull(stream.readBigDecimal()); 35 | rt = stream.readString(); 36 | name = stream.readString(); 37 | description = stream.readString(); 38 | 39 | } 40 | 41 | public void writeSQL(SQLOutput stream) throws SQLException { 42 | 43 | // Write data to stream 44 | stream.writeBigDecimal(Helpers.bigDecOrNull(id)); 45 | stream.writeString(Helpers.strOrNull(rt)); 46 | stream.writeString(Helpers.strOrNull(name)); 47 | stream.writeString(Helpers.strOrNull(description)); 48 | 49 | } 50 | 51 | public String getSQLTypeName() { 52 | 53 | return "NIPAP_VRF"; 54 | 55 | } 56 | 57 | /** 58 | * Create OVRF object from oracle.sql.STRUCT 59 | * 60 | * @param input STRUCT object contaning a NIPAP_VRF Oracle object 61 | * @return An OVRF instance 62 | */ 63 | static OVRF fromSTRUCT(STRUCT input) throws SQLException { 64 | 65 | if (input == null) { 66 | return null; 67 | } 68 | 69 | OVRF v = new OVRF(); 70 | Object[] val = input.getAttributes(); 71 | v.id = Helpers.integerOrNull((BigDecimal)val[0]); 72 | v.rt = (String)val[1]; 73 | v.name = (String)val[2]; 74 | v.description = (String)val[3]; 75 | 76 | return v; 77 | 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /pynipap/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include MANIFEST.in 3 | -------------------------------------------------------------------------------- /pynipap/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2011/04/18 17:14:00 lukagarb Exp $ 2 | # 3 | 4 | PYTHON=`which python3` 5 | DESTDIR=/ 6 | BUILDIR=$(CURDIR)/debian/python-pynipap-build 7 | PROJECT=pynipap 8 | 9 | all: 10 | @echo "make source - Create source package" 11 | @echo "make install - Install on local system" 12 | @echo "make buildrpm - Generate a rpm package" 13 | @echo "make builddeb - Generate a deb package" 14 | @echo "make bumpversion - Bump version to latest in ../NEWS file" 15 | @echo "make clean - Get rid of scratch and byte files" 16 | 17 | source: 18 | $(PYTHON) setup.py sdist 19 | 20 | install: 21 | $(PYTHON) setup.py install 22 | 23 | buildrpm: 24 | $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall 25 | 26 | builddeb: 27 | # build the source package in the parent directory 28 | # then rename it to project_version.orig.tar.gz 29 | $(PYTHON) -m build --sdist --outdir ../ 30 | rename -f 's/$(PROJECT)-(\d.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* 31 | # build the package 32 | debuild -us -uc 33 | 34 | distclean: 35 | realclean: 36 | test: 37 | check: 38 | 39 | upload: 40 | $(PYTHON) setup.py sdist upload 41 | 42 | clean: 43 | rm -rf .pybuild/ MANIFEST dist/ debian/files debian/python-pynipap* \ 44 | debian/python3-pynipap* debian/$(PROJECT).substvars debian/.debhelper \ 45 | debian/debhelper-build-stamp 46 | find . -name '*.pyc' -delete 47 | 48 | VER := $(shell head -n1 ../NEWS | awk '{print $$2}') 49 | bumpversion: 50 | # replace version number in pynipap.py 51 | sed -i 's/\(__version__\s*= \)"[^"]\+"/\1"$(VER)"/' pynipap/__init__.py 52 | # # update debian/changelog 53 | ../utilities/news2dch.py ../NEWS debian/changelog 54 | -------------------------------------------------------------------------------- /pynipap/README.rst: -------------------------------------------------------------------------------- 1 | PyNIPAP - a Python NIPAP client library 2 | ======================================= 3 | PyNIPAP is a Python client library to communicate with the NIPAP server via 4 | XML-RPC. It abstracts away all the evil in ze world. 5 | -------------------------------------------------------------------------------- /pynipap/debian/control: -------------------------------------------------------------------------------- 1 | Source: pynipap 2 | Maintainer: Lukas Garberg 3 | Section: python 4 | Priority: optional 5 | Build-Depends: debhelper-compat (= 13), 6 | dh-python, 7 | python3-all, 8 | python3-setuptools, 9 | pybuild-plugin-pyproject 10 | X-Python3-Version: >= 3.6 11 | Standards-Version: 4.6.1 12 | Homepage: https://spritelink.github.io/NIPAP/ 13 | 14 | Package: python3-pynipap 15 | Architecture: all 16 | Depends: ${misc:Depends}, ${python3:Depends} 17 | Breaks: ${python3:Breaks} 18 | Description: Python 3 module for accessing NIPAP 19 | This package contains a client library for NIPAP. It's function is similar to 20 | a simple ORM, which hides much of the complexity of working directly against 21 | the XML-RPC interface. 22 | -------------------------------------------------------------------------------- /pynipap/debian/copyright: -------------------------------------------------------------------------------- 1 | Package created by Lukas Garberg (lukagarb) 2 | on Fri, 7 Oct 2011 14:47:00 +0200. 3 | 4 | Upstream Author: 5 | 6 | Kristian Larsson (kll) 7 | Lukas Garberg (lukagarb) 8 | 9 | Files: * 10 | Copyright: 11 | 2011, Tele2 AB 12 | License: MIT 13 | 14 | License: MIT 15 | Copyright (C) 2011 by Kristian Larsson, Lukas Garberg 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /pynipap/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | export DH_VERBOSE=1 3 | export PYBUILD_NAME=pynipap 4 | 5 | %: 6 | dh $@ --with python3 --buildsystem=pybuild 7 | -------------------------------------------------------------------------------- /pynipap/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /pynipap/debian/source/options: -------------------------------------------------------------------------------- 1 | # Keep a few files out of the debian package 2 | extend-diff-ignore = "(^|/)(Makefile|MANIFEST)$" 3 | -------------------------------------------------------------------------------- /pynipap/pynipap/__init__.py: -------------------------------------------------------------------------------- 1 | from .pynipap import * 2 | 3 | __version__ = "0.32.7" 4 | __author__ = "Kristian Larsson, Lukas Garberg" 5 | __author_email__= "kll@tele2.net, lukas@spritelink.net" 6 | __copyright__ = "Copyright 2011, Kristian Larsson, Lukas Garberg" 7 | __license__ = "MIT" 8 | __status__ = "Development" 9 | __url__ = "http://SpriteLink.github.io/NIPAP" 10 | 11 | 12 | # This variable holds the URI to the nipap XML-RPC service which will be used. 13 | # It must be set before the Pynipap can be used! 14 | xmlrpc_uri = None 15 | 16 | # If set, the value assigned to the variable below will be used as a bearer 17 | # token. 18 | bearer_token = None 19 | 20 | # Caching of objects is enabled per default but can be disabled for certain 21 | # scenarios. Since we don't have any cache expiration time it can be useful to 22 | # disable for long running applications. 23 | CACHE = True 24 | -------------------------------------------------------------------------------- /pynipap/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "pynipap" 3 | dynamic = ["version", "description"] 4 | readme = "README.rst" 5 | license = {text = "MIT"} 6 | classifiers = [ 7 | 'Development Status :: 4 - Beta', 8 | 'Intended Audience :: Developers', 9 | 'Intended Audience :: System Administrators', 10 | 'License :: OSI Approved :: MIT License', 11 | 'Natural Language :: English', 12 | 'Operating System :: POSIX :: Linux', 13 | 'Programming Language :: Python :: 3' 14 | ] 15 | keywords = ["nipap"] 16 | 17 | [project.optional-dependencies] 18 | instrumentation = [ 19 | "opentelemetry-api==1.29.0", 20 | "opentelemetry-exporter-otlp==1.29.0", 21 | "opentelemetry-exporter-otlp-proto-common==1.29.0", 22 | "opentelemetry-exporter-otlp-proto-grpc==1.29.0", 23 | "opentelemetry-exporter-otlp-proto-http==1.29.0", 24 | "opentelemetry-proto==1.29.0", 25 | "opentelemetry-sdk==1.29.0", 26 | "opentelemetry-semantic-conventions==0.50b0", 27 | "opentelemetry-util-http==0.50b0" 28 | ] 29 | 30 | [project.urls] 31 | Homepage = "http://SpriteLink.github.io/NIPAP" 32 | 33 | [tool.setuptools.dynamic] 34 | version = {attr = "pynipap.__version__"} 35 | 36 | [build-system] 37 | requires = ["setuptools"] 38 | build-backend = "setuptools.build_meta" 39 | 40 | -------------------------------------------------------------------------------- /pynipap/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from setuptools import setup 4 | 5 | long_desc = open('README.rst').read() 6 | short_desc = long_desc.split('\n')[0].split(' - ')[1].strip() 7 | 8 | setup( 9 | description = short_desc, 10 | long_description = long_desc 11 | ) 12 | -------------------------------------------------------------------------------- /tests/performance/Makefile: -------------------------------------------------------------------------------- 1 | docs: 2 | rst2html README.rst > index.html 3 | -------------------------------------------------------------------------------- /tests/performance/README.rst: -------------------------------------------------------------------------------- 1 | ========================= 2 | NIPAP performance testing 3 | ========================= 4 | 5 | As NIPAP gained feature completeness one tends to focus on other areas and one of them is naturally performance. 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/performance/find-free-prefix/Makefile: -------------------------------------------------------------------------------- 1 | plot: 2 | rst2html README.rst > index.html 3 | -------------------------------------------------------------------------------- /tests/performance/insert/Makefile: -------------------------------------------------------------------------------- 1 | plot: 2 | octave -q insert.m 3 | rst2html README.rst > index.html 4 | -------------------------------------------------------------------------------- /tests/performance/insert/insert.m: -------------------------------------------------------------------------------- 1 | 2 | % 3 | 4 | % plot first graph - insertion time before optimization 5 | d0 = load('data.insert-start'); 6 | plot(d0(:,1), d0(:,2), 'r'); 7 | legend('baseline'); 8 | title('Prefix insertion time'); 9 | xlabel('Prefix number'); 10 | ylabel('Insert time [s]'); 11 | print('plot-before.png','-dpng','-S640,480'); 12 | 13 | hold('on'); 14 | % insertion time after optimization, retaining the old plot (ie before 15 | % optimization) and printing a combined graph 16 | d1 = load('data.insert-after-ip4r'); 17 | plot(d1(:,1), d1(:,2), 'b'); 18 | legend('before ip4r', 'after ip4r'); 19 | xlabel('Prefix number'); 20 | ylabel('Insert time [s]'); 21 | print('plot-before-and-after.png','-dpng','-S640,480'); 22 | 23 | % plot our long running test in a new graph 24 | hold('off'); 25 | d2 = load('data.insert-4610-24s'); 26 | plot(d2(:,1), d2(:,2), 'r'); 27 | legend('after ip4r'); 28 | title('Prefix insertion time'); 29 | xlabel('Prefix number'); 30 | ylabel('Insert time [s]'); 31 | print('plot-after-4610-24s.png','-dpng','-S640,480'); 32 | 33 | -------------------------------------------------------------------------------- /tests/performance/insert/plot-after-4610-24s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/tests/performance/insert/plot-after-4610-24s.png -------------------------------------------------------------------------------- /tests/performance/insert/plot-before-and-after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/tests/performance/insert/plot-before-and-after.png -------------------------------------------------------------------------------- /tests/performance/insert/plot-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpriteLink/NIPAP/6fe0614de5681cf494d49db21959856b34e4d995/tests/performance/insert/plot-before.png -------------------------------------------------------------------------------- /utilities/Makefile: -------------------------------------------------------------------------------- 1 | START=^ 2 | 3 | clean: 4 | for I in `seq 32|sort -nr`; do echo "Deleting IPv4 prefixes with length: $$I"; psql -c "DELETE FROM ip_net_plan WHERE family(prefix) = 4 AND masklen(prefix)=$$I" nap > /dev/null; done ; 5 | 6 | transfer: 7 | rm -f 1 2 8 | scp $(TEXTFILE) 1 9 | chmod u+w 1 10 | 11 | utf8: 12 | iconv --from iso-8859-1 --to utf-8 1 > 2 13 | mv 2 1 14 | 15 | except: 16 | grep -v -f exceptions 1 > 2 17 | mv 2 1 18 | 19 | import: 20 | ./text-import.py --schema global --url http://dev@local:dev@127.0.0.1:1337 1 21 | 22 | genpartial: 23 | sed -ne '/$(START)/,$$p' 1 > 2 24 | mv 2 1 25 | 26 | reread: clean except genpartial import 27 | 28 | full: clean transfer utf8 except genpartial import 29 | 30 | partial: clean transfer utf8 except genpartial import 31 | -------------------------------------------------------------------------------- /utilities/boilerplate.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | """ This is a boilerplate for interacting with NIPAP using Pynipap 3 | 4 | It provides things such as basic command line parsing of connection options 5 | for the backend or reading the users .nipaprc file for getting connectivity 6 | settings. 7 | """ 8 | 9 | import ConfigParser 10 | import os 11 | # use local pynipap, useful if we are developing 12 | import sys 13 | sys.path.append('../pynipap') 14 | from pynipap import Prefix, Pool, VRF 15 | import pynipap 16 | 17 | # 18 | # Fill in your code here 19 | # 20 | 21 | 22 | if __name__ == '__main__': 23 | # read configuration 24 | cfg = ConfigParser.ConfigParser() 25 | cfg.read(os.path.expanduser('~/.nipaprc')) 26 | 27 | import argparse 28 | parser = argparse.ArgumentParser() 29 | parser.add_argument('--username', help="NIPAP backend username") 30 | parser.add_argument('--password', help="NIPAP backend password") 31 | parser.add_argument('--host', help="NIPAP backend host") 32 | parser.add_argument('--port', help="NIPAP backend port") 33 | args = parser.parse_args() 34 | 35 | auth_uri = "%s:%s@" % (args.username or cfg.get('global', 'username'), 36 | args.password or cfg.get('global', 'password')) 37 | 38 | xmlrpc_uri = "http://%(auth_uri)s%(host)s:%(port)s" % { 39 | 'auth_uri' : auth_uri, 40 | 'host' : args.host or cfg.get('global', 'hostname'), 41 | 'port' : args.port or cfg.get('global', 'port') 42 | } 43 | pynipap.AuthOptions({ 'authoritative_source': 'nipap' }) 44 | pynipap.xmlrpc_uri = xmlrpc_uri 45 | 46 | -------------------------------------------------------------------------------- /utilities/export-csv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ Example script for CSV export 3 | 4 | This script likely need to be modified to meet your needs but can act as a 5 | starting point for the less experienced. 6 | """ 7 | 8 | import os 9 | import csv 10 | 11 | import sys 12 | sys.path.append('../pynipap') 13 | import pynipap 14 | 15 | class Export: 16 | def __init__(self, xmlrpc_uri): 17 | self.xmlrpc_uri = xmlrpc_uri 18 | 19 | 20 | def write(self, output_file, query): 21 | """ 22 | """ 23 | f = open(output_file, "w+") 24 | writer = csv.writer(f, quoting=csv.QUOTE_MINIMAL) 25 | 26 | pynipap.xmlrpc_uri = xmlrpc_uri 27 | ao = pynipap.AuthOptions({ 'authoritative_source': 'nipap' }) 28 | 29 | import socket,xmlrpclib 30 | try: 31 | res = pynipap.Prefix.smart_search(query, {}) 32 | except socket.error: 33 | print >> sys.stderr, "Connection refused, please check hostname & port" 34 | sys.exit(1) 35 | except xmlrpclib.ProtocolError: 36 | print >> sys.stderr, "Authentication failed, please check your username / password" 37 | sys.exit(1) 38 | 39 | for p in res['result']: 40 | writer.writerow([p.vrf.rt, p.display_prefix, p.type, p.node, p.order_id, p.customer_id, p.description]) 41 | 42 | 43 | if __name__ == '__main__': 44 | import argparse 45 | parser = argparse.ArgumentParser() 46 | parser.add_argument('--username', default='', help="Username") 47 | parser.add_argument('--password', default='', help="Password") 48 | parser.add_argument('--host', help="NIPAP backend host") 49 | parser.add_argument('--port', default=1337, help="NIPAP backend port") 50 | parser.add_argument('--query', default = '', help="A prefix query string") 51 | parser.add_argument('--file', help="Output file") 52 | 53 | args = parser.parse_args() 54 | 55 | if args.host is None: 56 | print >> sys.stderr, "Please specify the NIPAP backend host to work with" 57 | sys.exit(1) 58 | 59 | if args.file is None: 60 | print >> sys.stderr, "Please specify an output file" 61 | sys.exit(1) 62 | 63 | auth_uri = '' 64 | if args.username: 65 | auth_uri = "%s:%s@" % (args.username, args.password) 66 | 67 | xmlrpc_uri = "http://%(auth_uri)s%(host)s:%(port)s" % { 68 | 'auth_uri' : auth_uri, 69 | 'host' : args.host, 70 | 'port' : args.port 71 | } 72 | 73 | wr = Export(xmlrpc_uri) 74 | wr.write(args.file, args.query) 75 | -------------------------------------------------------------------------------- /utilities/export-isc-dhcp.template: -------------------------------------------------------------------------------- 1 | # 2 | # ISC DHCP config file 3 | # 4 | 5 | option domain-name "example.com"; 6 | default-lease-time 600; 7 | max-lease-time 7200; 8 | 9 | {% for prefix in prefixes %} 10 | # {{prefix.description}} 11 | subnet {{prefix.prefix_ipy.strNormal(0)}} {{prefix.prefix_ipy.strNetmask()}} { 12 | range {{prefix.prefix_ipy[10]}} {{prefix.prefix_ipy[-2]}}; 13 | option routers {{prefix.prefix_ipy[1]}}; 14 | option subnet-mask {{prefix.prefix_ipy.strNetmask()}}; 15 | option broadcast-address {{prefix.prefix_ipy[-1]}}; 16 | } 17 | {% endfor %} 18 | -------------------------------------------------------------------------------- /utilities/install-ip4r.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # set the postgres password we'll be using in our testing 4 | export PGPASSWORD=papin 5 | 6 | # create the database 7 | cd nipap/sql/ 8 | sudo -u postgres PGPASSWORD=papin make db 9 | cd ../.. 10 | 11 | # install ip4r 12 | mkdir ip4r 13 | cd ip4r 14 | wget http://pgfoundry.org/frs/download.php/3380/ip4r-2.0.tgz 15 | tar zxf ip4r-2.0.tgz 16 | cd ip4r-2.0 17 | make 18 | sudo make install > ip4r-make.log 2>&1 19 | sudo -u postgres psql -d nipap -f sql/ip4r.sql > ip4r-sql-install.log 2>&1 20 | cd ../.. 21 | 22 | # create the nipap tables 23 | cd nipap/sql/ 24 | sudo -u postgres PGPASSWORD=papin make tables 25 | -------------------------------------------------------------------------------- /utilities/remove_expired.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | """ Script to remove prefixes that has expired in NIPAP 3 | 4 | This script removes prefixes in NIPAP with status quarantine 5 | and that has expired. 6 | 7 | Usage: 8 | 9 | When the script is executed, it deletes all prefixes with status 10 | "quarantine" and where the expires date has passed. 11 | 12 | Prefixes within prefixes are recursively deleted only if the 13 | type is Assigned. 14 | """ 15 | 16 | import os 17 | import sys 18 | import socket 19 | import argparse 20 | from datetime import datetime 21 | import configparser 22 | 23 | from pynipap import Prefix, NipapAuthError 24 | import pynipap 25 | 26 | def _remove_expired_prefixes(): 27 | query = { 28 | 'operator': 'and', 29 | 'val1': { 30 | 'operator': 'equals', 31 | 'val1': 'status', 32 | 'val2': 'quarantine' 33 | }, 34 | 'val2': { 35 | 'operator': 'less_or_equal', 36 | 'val1': 'expires', 37 | 'val2': 'Now()' 38 | } 39 | } 40 | 41 | try: 42 | res = Prefix.search(query) 43 | 44 | except socket.error: 45 | print("Connection refused, please check hostname and port", file=sys.stderr) 46 | sys.exit(1) 47 | except NipapAuthError: 48 | print("Authentication error, please check your username / password", file=sys.stderr) 49 | sys.exit(1) 50 | except Exception as exc: 51 | print("Error: %s" %str(exc), file=sys.stderr) 52 | sys.exit(1) 53 | 54 | prefixes = res['result'] 55 | 56 | if len(prefixes) > 0: 57 | print("%s: Expired quarantined prefixes found, they will be removed" %datetime.now().strftime("%Y-%m-%d, %H:%M:%S")) 58 | 59 | for p in prefixes: 60 | recursive = True if p.type == "assignment" else False 61 | p.remove(recursive) 62 | print("Removed prefix %s" %p.prefix) 63 | 64 | if len(prefixes) > 0: 65 | print("Removed %s expired prefixes" %str(len(prefixes))) 66 | 67 | 68 | if __name__ == '__main__': 69 | # read configuration 70 | cfg = configparser.ConfigParser() 71 | cfg.read(os.path.expanduser('~/.nipaprc')) 72 | 73 | parser = argparse.ArgumentParser() 74 | parser.add_argument('--username', help="NIPAP backend username") 75 | parser.add_argument('--password', help="NIPAP backend password") 76 | parser.add_argument('--host', help="NIPAP backend host") 77 | parser.add_argument('--port', help="NIPAP backend port") 78 | args = parser.parse_args() 79 | 80 | auth_uri = "%s:%s@" % (args.username or cfg.get('global', 'username'), 81 | args.password or cfg.get('global', 'password')) 82 | 83 | xmlrpc_uri = "http://%(auth_uri)s%(host)s:%(port)s" % { 84 | 'auth_uri' : auth_uri, 85 | 'host' : args.host or cfg.get('global', 'hostname'), 86 | 'port' : args.port or cfg.get('global', 'port') 87 | } 88 | pynipap.AuthOptions({'authoritative_source': 'Expired quarantined prefixes removal script'}) 89 | pynipap.xmlrpc_uri = xmlrpc_uri 90 | 91 | _remove_expired_prefixes() 92 | 93 | print("Done") 94 | 95 | -------------------------------------------------------------------------------- /whoisd/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst MANIFEST.in 2 | prune Makefile 3 | prune debian/* 4 | -------------------------------------------------------------------------------- /whoisd/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.6 2012/02/29 08:55:00 lukagarb Exp $ 2 | # 3 | 4 | PYTHON=`which python3` 5 | DESTDIR=/ 6 | BUILDIR=$(CURDIR)/debian/python-nipap-build 7 | PROJECT=nipap-whoisd 8 | 9 | all: 10 | @echo "make source - Create source package" 11 | @echo "make install - Install on local system" 12 | @echo "make buildrpm - Generate a rpm package" 13 | @echo "make builddeb - Generate a deb package" 14 | @echo "make bumpversion - Bump version to latest in ../NEWS file" 15 | @echo "make clean - Get rid of scratch and byte files" 16 | 17 | source: 18 | $(PYTHON) setup.py sdist 19 | 20 | install: 21 | $(PYTHON) setup.py install 22 | 23 | buildrpm: 24 | $(PYTHON) setup.py bdist_rpm --post-install=rpm/postinstall --pre-uninstall=rpm/preuninstall 25 | 26 | builddeb: 27 | # build the source package in the parent directory 28 | # then rename it to project_version.orig.tar.gz 29 | $(PYTHON) -m build --sdist --outdir=../ 30 | rename -f 's/nipap_whoisd-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../* 31 | # build the package 32 | debuild -us -uc 33 | 34 | distclean: 35 | realclean: 36 | test: 37 | check: 38 | 39 | upload: 40 | $(PYTHON) setup.py sdist upload 41 | 42 | clean: 43 | $(PYTHON) setup.py clean 44 | rm -rf .pybuild/ MANIFEST dist/ debian/tmp debian/$(PROJECT) debian/files \ 45 | .pc/ debian/$(PROJECT).debhelper.log debian/$(PROJECT).postinst.debhelper \ 46 | debian/$(PROJECT).prerm.debhelper debian/$(PROJECT).postrm.debhelper \ 47 | debian/$(PROJECT).substvars nipap-whoisd.8 debian/.debhelper \ 48 | debian/debhelper-build-stamp nipap_whoisd.egg-info 49 | find . -name '*.pyc' -delete 50 | 51 | VER := $(shell head -n1 ../NEWS | awk '{print $$2}') 52 | bumpversion: 53 | # replace version number in nipap_whoisd.py 54 | sed -i 's/\(__version__\s*= \)"[^"]\+"/\1"$(VER)"/' nipap_whoisd.py 55 | # update debian/changelog 56 | ../utilities/news2dch.py ../NEWS debian/changelog 57 | -------------------------------------------------------------------------------- /whoisd/README.rst: -------------------------------------------------------------------------------- 1 | nipap-whoisd - the NIPAP whois daemon 2 | ===================================== 3 | The NIPAP whois daemon provides a whois-style interface for querying data in 4 | the NIPAP database. It receives whois queries, translates these into search 5 | queries towards the nipapd backend and sends the result, with a whois style 6 | format, back to the client. 7 | -------------------------------------------------------------------------------- /whoisd/debian/config: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Source debconf library. 4 | . /usr/share/debconf/confmodule 5 | 6 | # should nipap-whoisd be started on system boot? 7 | db_input high nipap-whoisd/startup || true 8 | db_go 9 | -------------------------------------------------------------------------------- /whoisd/debian/control: -------------------------------------------------------------------------------- 1 | Source: nipap-whoisd 2 | Maintainer: Kristian Larsson 3 | Section: python 4 | Priority: optional 5 | Build-Depends: debhelper-compat (= 13), 6 | dh-python, 7 | python3-all, 8 | python3-setuptools 9 | Standards-Version: 4.6.1 10 | 11 | Package: nipap-whoisd 12 | Architecture: all 13 | Depends: ${misc:Depends}, ${python3:Depends} 14 | Description: Neat IP Address Planner 15 | The NIPAP whois daemon provides a whois-style interface for querying data in 16 | the NIPAP backend. It receives whois queries, translates these into search 17 | queries towards the nipapd backend and sends the result, with a whois style 18 | format, back to the client. 19 | -------------------------------------------------------------------------------- /whoisd/debian/copyright: -------------------------------------------------------------------------------- 1 | Package created by Kristian Larsson (kll) 2 | on Thu, 13 Feb 2014 08:29:00 +0200. 3 | 4 | Upstream Author: 5 | 6 | Kristian Larsson (kll) 7 | Lukas Garberg (lukagarb) 8 | 9 | Files: * 10 | Copyright: 11 | 2014, Tele2 AB 12 | License: MIT 13 | 14 | License: MIT 15 | Copyright (C) 2011 by Kristian Larsson, Lukas Garberg 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | -------------------------------------------------------------------------------- /whoisd/debian/default: -------------------------------------------------------------------------------- 1 | # defaults file for nipap-whoisd 2 | 3 | RUN=no 4 | -------------------------------------------------------------------------------- /whoisd/debian/init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | ### BEGIN INIT INFO 6 | # Provides: nipap-whoisd 7 | # Required-Start: $remote_fs $network 8 | # Required-Stop: $remote_fs $network 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: NIPAP whois daemon 12 | ### END INIT INFO 13 | 14 | DAEMON=/usr/bin/nipap-whoisd 15 | CONFIGFILE=/etc/nipap/whoisd.conf 16 | NAME=nipap-whoisd 17 | LONGNAME="NIPAP whois daemon" 18 | PIDFILE=/var/run/nipap-whoisd/whoisd.pid 19 | PIDDIR=`dirname $PIDFILE` 20 | DEFAULTS=/etc/default/nipap-whoisd 21 | 22 | . /lib/lsb/init-functions 23 | 24 | RUN=no 25 | # include defaults if available 26 | if [ -f $DEFAULTS ]; then 27 | . $DEFAULTS 28 | fi 29 | 30 | if [ "$RUN" != "yes" ]; then 31 | log_action_msg "$NAME disabled; edit $DEFAULTS" 32 | exit 0 33 | fi 34 | 35 | running() { 36 | # create dir for PID file if it doesn't exist 37 | if [ ! -d "$PIDDIR" ]; then 38 | mkdir "$PIDDIR" 39 | chown nobody:nogroup $PIDDIR 40 | fi 41 | 42 | if [ $(flock -xn $PIDFILE -c 'echo 1' 2> /dev/null) ]; then 43 | echo -n 44 | rm -f $PIDFILE > /dev/null 2>&1 45 | else 46 | cat $PIDFILE || echo -n 47 | fi 48 | } 49 | 50 | 51 | case "$1" in 52 | start) 53 | log_daemon_msg "Starting $LONGNAME" "$NAME" 54 | RUNNING=$(running) 55 | if [ -n "$RUNNING" ]; then 56 | log_progress_msg "already running" 57 | log_end_msg 0 58 | else 59 | if start-stop-daemon --start --exec $DAEMON -- --config $CONFIGFILE; then 60 | log_end_msg 0 61 | else 62 | log_end_msg 1 63 | fi 64 | fi 65 | ;; 66 | stop) 67 | log_daemon_msg "Stopping $LONGNAME" "$NAME" 68 | RUNNING=$(running) 69 | if [ -n "$RUNNING" ]; then 70 | if start-stop-daemon --stop --pidfile $PIDFILE --retry 30; then 71 | log_end_msg 0 72 | else 73 | log_end_msg 1 74 | fi 75 | else 76 | log_end_msg 0 77 | fi 78 | ;; 79 | restart) 80 | log_daemon_msg "Restarting $LONGNAME" "$NAME" 81 | RUNNING=$(running) 82 | if [ -n "$RUNNING" ]; then 83 | if start-stop-daemon --stop --pidfile $PIDFILE; then 84 | if start-stop-daemon --start --exec $DAEMON -- --config $CONFIGFILE; then 85 | log_end_msg 0 86 | else 87 | log_end_msg 1 88 | fi 89 | else 90 | log_end_msg 1 91 | fi 92 | else 93 | if start-stop-daemon --start --exec $DAEMON -- --config $CONFIGFILE; then 94 | log_end_msg 0 95 | else 96 | log_end_msg 1 97 | fi 98 | fi 99 | ;; 100 | status) 101 | RUNNING=$(running) 102 | if [ -n "$RUNNING" ]; then 103 | log_success_msg "$LONGNAME running with PID $RUNNING" 104 | exit 0 105 | else 106 | log_failure_msg "$LONGNAME not running" 107 | exit 3 108 | fi 109 | ;; 110 | *) 111 | log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart|status}" 112 | esac 113 | 114 | exit 0 115 | -------------------------------------------------------------------------------- /whoisd/debian/install: -------------------------------------------------------------------------------- 1 | whoisd.conf.dist etc/nipap 2 | -------------------------------------------------------------------------------- /whoisd/debian/nipap-whoisd.manpages: -------------------------------------------------------------------------------- 1 | nipap-whoisd.8 2 | -------------------------------------------------------------------------------- /whoisd/debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #set -e 4 | 5 | # Source debconf library. 6 | . /usr/share/debconf/confmodule 7 | 8 | case "$1" in 9 | configure) 10 | # autostart? 11 | db_get nipap-whoisd/startup 12 | if [ "$RET" = "true" ]; then 13 | sed -i -e 's/RUN=.*/RUN=yes/' /etc/default/nipap-whoisd 14 | update-rc.d nipap-whoisd defaults >/dev/null 2>&1 15 | else 16 | sed -i -e 's/RUN=.*/RUN=no/' /etc/default/nipap-whoisd 17 | update-rc.d nipap-whoisd remove >/dev/null 2>&1 18 | fi 19 | ;; 20 | esac 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /whoisd/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # This file was automatically generated by stdeb 0.6.0+git at 4 | # Wed, 29 Feb 2012 09:03:22 +0100 5 | 6 | %: 7 | dh $@ --with python3 --buildsystem=pybuild 8 | -------------------------------------------------------------------------------- /whoisd/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /whoisd/debian/source/options: -------------------------------------------------------------------------------- 1 | # Don't store "changes" made to Makefile 2 | extend-diff-ignore = "(^|/)(Makefile|MANIFEST|nipap-whoisd.man.rst)$" 3 | -------------------------------------------------------------------------------- /whoisd/debian/templates: -------------------------------------------------------------------------------- 1 | Template: nipap-whoisd/startup 2 | Type: boolean 3 | Default: false 4 | Description: Start nipap-whoisd automatically? 5 | The NIPAP whois daemon, nipap-whoisd, can can be automatically started on 6 | system startup by inclusion in the system startup scripts. 7 | -------------------------------------------------------------------------------- /whoisd/nipap-whoisd.man.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | nipap-whoisd 3 | ============ 4 | 5 | The NIPAP whois daemon 6 | ====================== 7 | 8 | Synopsis 9 | -------- 10 | **nipap-whoisd** [option...] 11 | 12 | Description 13 | ----------- 14 | **nipap-whoisd** is a whois frontend to the NIPAP backend. It will listen on 15 | the standard whois port and "translate" between received whois queries and the 16 | NIPAP XML-RPC format that the NIPAP backend service speaks. 17 | 18 | Options 19 | ------- 20 | **nipap-whoisd** accepts the following command-line arguments. 21 | 22 | -h, --help show a help message 23 | --config=CONFIG_FILE read configuration from file **CONFIG_FILE** [default: /etc/nipap/nipap-whoisd.conf] 24 | --listen=ADDRESS listen on IPv4/6 **ADDRESS** 25 | --port=PORT port to listen on 26 | --pid-file=PID_FILE write a PID file to **PID_FILE** 27 | --no-pid-file turn off writing PID file 28 | --version display version information and exit 29 | 30 | Copyright 31 | --------- 32 | Kristian Larsson, Lukas Garberg 2011-2014 33 | -------------------------------------------------------------------------------- /whoisd/pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "nipap-whoisd" 3 | dynamic = ["version", "description"] 4 | readme = "README.rst" 5 | license = {text = "MIT"} 6 | classifiers = [ 7 | 'Development Status :: 4 - Beta', 8 | 'Intended Audience :: Developers', 9 | 'Intended Audience :: System Administrators', 10 | 'Intended Audience :: Telecommunications Industry', 11 | 'License :: OSI Approved :: MIT License', 12 | 'Natural Language :: English', 13 | 'Operating System :: POSIX :: Linux', 14 | 'Programming Language :: Python :: 3', 15 | 'Topic :: Internet' 16 | ] 17 | keywords = ["nipap"] 18 | dependencies = [ 19 | "pynipap" 20 | ] 21 | 22 | [project.urls] 23 | Homepage = "http://SpriteLink.github.io/NIPAP" 24 | 25 | [tool.setuptools.dynamic] 26 | version = {attr = "nipap_whoisd.__version__"} 27 | 28 | [build-system] 29 | requires = [ 30 | "setuptools", 31 | # Need to be pinned to 0.20.1 in Ubuntu 24.04 as using the latest 0.21.2 32 | # gives a diff during .deb package build. Unfortunately the files are 33 | # generated twice - first once in a virtualenv (using the version specified 34 | # here) and then once without a virtualenv using the one from the system. 35 | # There two runs produce different outputs (wich they shouldn't) causing a 36 | # diff and the package utils to b0rk out. 37 | "docutils==0.20.1" 38 | ] 39 | build-backend = "setuptools.build_meta" 40 | -------------------------------------------------------------------------------- /whoisd/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from setuptools import setup 4 | import sys 5 | 6 | from docutils.core import publish_cmdline 7 | from docutils.writers import manpage 8 | 9 | 10 | # return all the extra data files 11 | def get_data_files(): 12 | # generate man pages using rst2man 13 | try: 14 | publish_cmdline(writer=manpage.Writer(), argv=["nipap-whoisd.man.rst", "nipap-whoisd.8"]) 15 | except Exception as exc: 16 | print("Failed to compile man file: {}".format(str(exc)), file=sys.stderr) 17 | sys.exit(1) 18 | 19 | files = [ 20 | ('share/nipap/', ['whoisd.conf.dist']), 21 | ('bin/', ['nipap-whoisd']), 22 | ('share/man/man8/', ['nipap-whoisd.8']) 23 | ] 24 | 25 | return files 26 | 27 | 28 | long_desc = open('README.rst').read() 29 | short_desc = long_desc.split('\n')[0].split(' - ')[1].strip() 30 | 31 | setup( 32 | description = short_desc, 33 | long_description = long_desc, 34 | py_modules = ['nipap_whoisd'], 35 | data_files = get_data_files(), 36 | ) 37 | -------------------------------------------------------------------------------- /whoisd/whoisd.conf.dist: -------------------------------------------------------------------------------- 1 | # ------------------------------- 2 | # NIPAP whoisd configuration file 3 | # ------------------------------- 4 | # 5 | # This file consists mostly of lines of the form: 6 | # 7 | # name = value 8 | # 9 | # Where name is the name of an option and value is its value. Value may be 10 | # empty. Options are further grouped into sections, which start with: 11 | # 12 | # [section] 13 | # 14 | # There is no explicit marker for the end of a section. All options following a 15 | # section header is interpreted as belonging to that section. Please be aware 16 | # of which section you edit. 17 | # 18 | # Lines starting with "#" or ";" are interpreted as a comments. It may not 19 | # contain leading whitespace! Comments may also appear on lines holding values 20 | # or section names but must be prefaced with whitespace followed by ";". Lines 21 | # starting with whitespace is interpreted as a continuation of the value on the 22 | # previous option-value line. 23 | # 24 | # The commented-out settings shown represent the default values in most cases. 25 | # 26 | 27 | [whoisd] 28 | # Run nipap-whoisd as a different user, ie drop privileges from root to the 29 | # specified user and group. If no user is specified, nipap-whoisd will run as 30 | # the user who started it (typically root). If only user but no group is 31 | # specified, the value for user will be used for group as well. 32 | user = nobody 33 | group = nogroup 34 | 35 | # listen on all addresses, both IPv4 and IPv6 per default. Note that if you 36 | # want to listen to an IPv4 address you need to specify it as a IPv4-mapped 37 | # IPv6 address, ie to listen on 127.0.0.1, specify ::FFFF:127.0.0.1 38 | listen = :: ; IPv6 address to listen on. 39 | port = 43 ; XML-RPC listen port (change requires restart) 40 | pid_file = /var/run/nipap-whoisd/whoisd.pid 41 | 42 | # 43 | # - nipapd connection - 44 | # the following parameters control how nipap-whoisd connects to the nipapd 45 | # backend 46 | # 47 | nipapd_host = localhost ; nipapd hostname 48 | nipapd_port = 1337 ; nipapd port 49 | #nipapd_username = fillmein ; nipapd username 50 | #nipapd_password = fillmein ; nipapd password 51 | --------------------------------------------------------------------------------