Browse Source

Licensing for GPL-2.0-or-later added.

REST API URL updated.
JSON exception handled.

Signed-off-by: Birin Sanchez <birin.sanchez@puri.sm>
master
Birin Sanchez 1 year ago
parent
commit
e8568e401a
3 changed files with 57 additions and 2 deletions
  1. +0
    -0
      COPYING.AGPL.md
  2. +44
    -0
      COPYING.md
  3. +13
    -2
      scripts/nm_tunnel_setup.py

+ 0
- 0
COPYING.AGPL.md View File


+ 44
- 0
COPYING.md View File

@@ -0,0 +1,44 @@
# Copying notice

Liberty CLI
<https://source.puri.sm/liberty/ldh_client>
Copyright 2017-2019 Purism SPC
SPDX-License-Identifier: AGPL-3.0-or-later

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

## Notices for included code

All code is covered by and compatible with the "Copying notice" above.
Some code copied from other sources comes with additional notices. These
are listed below, and also appear in the files where that code appears.

---

Network-Manager tunnel setup code includes some code from
Network-Manager Pyhton examples: <br />
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/blob/master/examples/python/gi/vpn-import.py <br />
Copyright 2014 Red Hat, Inc.<br />
SPDX-License-Identifier: GPL-2.0-or-later

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Copyright 2014 Red Hat, Inc.

+ 13
- 2
scripts/nm_tunnel_setup.py View File

@@ -1,4 +1,11 @@
#!/usr/bin/env python3
# Copyright 2017-2019 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later

# Original file from Network-Manager Python examples
# Copyright 2014 Red Hat, Inc.
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/blob/master/examples/python/gi/vpn-import.py
# SPDX-License-Identifier: GPL-2.0-or-later

import sys
import os
@@ -6,12 +13,13 @@ import requests
import gi
from tempfile import mkstemp
from getpass import getpass
from json.decoder import JSONDecodeError
gi.require_version('NM', '1.0')
from gi.repository import NM, GLib

PROTO = 'https://'
HOST = 'librem.one'
PATH = '/tunnel/api/v1/get_user_creds'
PATH = '/api/v1/user/tunnel_account'
CERT_PATH = '/public/certificate.ovpn'
DOMAIN = 'librem.one'
QQN = 'US1'
@@ -38,7 +46,10 @@ def nm_tunnel_setup():
sys.exit(1)
else:
print('\nSomething went wrong when connecting to', url)
detail = r.json().get('detail', 'No detail available')
try:
detail = r.json().get('detail', 'No detail available')
except JSONDecodeError as e:
detail = r.reason
print('Problem details:', detail)
sys.exit(1)



Loading…
Cancel
Save