Commit Graph

72 Commits

Author SHA1 Message Date
Kris Moore
cbf3ce8b8b Add new API call to schedule a cron scrub
Frequency Options: none, daily@XX, weekly@YY@XX, monthly@ZZ@XX
XX = Hour to execute, YY = Day of week to execute, ZZ = Day of month

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "cronscrub",
   "pool" : "tank",
   "frequency" : "daily@22"
}

REST Response:
-------------------------------
{
    "args": {
        "cronscrub": {
            "frequency": "daily@22",
            "pool": "tank"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "cronscrub",
      "pool" : "tank",
      "frequency" : "daily@22"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "cronscrub": {
      "frequency": "daily@22",
      "pool": "tank"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 12:12:19 -05:00
Luke De Mouy
58db613ab7 Refactor to use Range Based For Loops since C++11 is enabled, also add
in LoadOpenPorts to the function to reset to the default config, so that
we have the correct set of open ports.
2016-01-12 02:58:35 -07:00
Luke De Mouy
43a4274565 Add in the ability to close or open multiple ports at once, by passing
in a QVector<PortInfo> to the OpenPort and ClosePort functions,
2016-01-12 02:37:07 -07:00
Luke De Mouy
aec5ce9aeb Move the #include<tuple> to where it should be in the header file as
opposed to the cpp
2016-01-12 02:26:06 -07:00
Luke De Mouy
4645d2fa20 rename PortType to Type, and simply the argument names from functions
from portType and portNumber to type and number respectively
2016-01-11 19:38:42 -07:00
Luke De Mouy
20ee1eaf62 Switch openports from being a nonintuitive string to using our PortInfo
struct and add comments to the /etc/ipfw.openports file when we write to
it.

Enable C++11 in the library.pro file as it's required for std::sort and
std::tie, since qSort is deprecated as of Qt 5.3
2016-01-11 19:28:02 -07:00
Luke De Mouy
17d2c131b5 Add in the option to restore the default configuration 2016-01-11 15:02:07 -07:00
Luke De Mouy
21f5cf6265 Add license header on firewall cpp file 2016-01-11 14:29:42 -07:00
Luke De Mouy
38ff401f11 Copy the functionality from the original utility into the Firewall
class, in particular adds in the following functionality:
Start, Stop, and Restart the firewall, and see if it's running
Open or Close a port, and get a list of the ports that are currently
open.

UI code was removed, and functions were modified as appropriate.
2016-01-11 14:17:02 -07:00
Ken Moore
35c090da89 Merge pull request #1 from ldemouy/master
Adds in the LookUpPort function call as well as the basic framework for a new sysadm-firewall management class.
2016-01-11 14:27:45 -05:00
Luke De Mouy
a326c3f811 renamed PortLookUp to firewall, and the files to sysadm-firewall 2016-01-11 12:22:54 -07:00
Luke De Mouy
fb508a8352 Move PortInfo struct out of PortLookUp class, and fiddled with the regex
to make it actually work based on testing. The filter operation now will
pickup things like 522/tcp in the QStringList if you're searching for
22/tcp, but testing seems to indicate that just taking the first one in
the list works for getting what we want.
2016-01-09 13:00:23 -07:00
Kris Moore
4c562a85b2 Add a new API call to create snapshot schedules for LifePreserver
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "pool" : "mytank",
   "keep" : "10",
   "frequency" : "daily@11",
   "action" : "cronsnap"
}

REST Response:
-------------------------------
{
    "args": {
        "cronsnap": {
            "frequency": "daily@11",
            "keep": "10",
            "pool": "mytank"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "cronsnap",
      "keep" : "10",
      "frequency" : "daily@11",
      "pool" : "mytank"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "cronsnap": {
      "frequency": "daily@11",
      "keep": "10",
      "pool": "mytank"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-08 15:52:09 -05:00
Kris Moore
9160af8912 Add a new API call for sysadm/lifepserver which returns the system-wide
settings of the utility

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "settings"
}

REST Response:
-------------------------------
{
    "args": {
        "settings": {
            "diskwarn": "85%",
            "email": "WARN",
            "emailaddress": "krismoore134@gmail.com",
            "recursive": "ON"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "action" : "settings"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "settings": {
      "diskwarn": "85%",
      "email": "WARN",
      "emailaddress": "krismoore134@gmail.com",
      "recursive": "ON"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-08 14:47:55 -05:00
Ken Moore
eee477167b Fix the cert/key paths used for the websocket server. 2016-01-08 14:12:22 -05:00
Ken Moore
e119e6f25a Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-08 14:02:20 -05:00
Ken Moore
262ddb637d Commit some more work on on updating the websocket server to use wss. 2016-01-08 14:01:49 -05:00
Kris Moore
1ceb256922 Add the new listsnap API call 2016-01-08 13:48:51 -05:00
Ken Moore
ba654808db Get the TCP server running with SSL encryption all the time now (TLS1.2) 2016-01-08 12:07:17 -05:00
Ken Moore
fbbc72c3a4 Commit some more work converting the QTcpServer into an SslServer. The API test will now connect without failures - but it hangs there (no incoming messages detected) 2016-01-08 10:33:01 -05:00
Luke De Mouy
5cc11be9e6 add the port type to the PortInfo struct 2016-01-07 16:55:04 -07:00
Luke De Mouy
26f51d6822 Make portlookup take the port type into consideration when checking the
port
2016-01-07 16:42:11 -07:00
Ken Moore
8abeeac890 Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-07 16:08:11 -05:00
Ken Moore
cce21a7677 Switch the sysadm server over to the secure socket protocols (wss/https) 2016-01-07 16:07:35 -05:00
Kris Moore
dbbef963ed Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-01-07 15:41:09 -05:00
Kris Moore
aadcc88b4e Auto-generate SSL certs we can use for REST/WS servers 2016-01-07 15:40:43 -05:00
Ken Moore
40a7e41213 Fix a bug with event notifications and the new output structure (ensure it sets the output data properly). 2016-01-07 15:14:46 -05:00
Luke De Mouy
bdac469ed3 remove unnecessary <string> include, delete the QFile once we're done
with it. Add in a constructor that initializes the port cache, and add
in a destructor to delete the cache if portlookup is deleted.
2016-01-07 03:39:50 -07:00
Luke De Mouy
19c072bc81 update library.pro to build the portlookup class
Refactor portlookup from a function that reads a file each time it is
called to a class that reads the file into a QStringList the first time
that it is called and reuses it afterwards.
2016-01-06 18:04:47 -07:00
Luke De Mouy
37c6b2a7c9 Adds in the LookUpPort function call that returns a struct containing
information about a port including it's description and keyword.
SSH and the web port are current placeholders for the recommended ports list
2016-01-06 12:59:00 -07:00
Kris Moore
2bfdc0928b Fixed up the way REST / HTTP1.1 messages are formatted when passed
back to the client. Fixes an issue with bad header formatting, and
changed JSON to be more human-readable.

Also, changed the test script to only display the verbose error
output if it fails, otherwise it'll just return the JSON response
2016-01-05 17:55:22 -05:00
Ken Moore
7ffec5003b Add PUT REST support, and clean up the bytes calculation for the output JSON data. 2016-01-05 16:20:37 -05:00
Ken Moore
b425c7bb89 Allow "Post" Requests from REST input. 2016-01-05 15:54:55 -05:00
Ken Moore
838a5d9f60 Fix up some REST input parsing. 2016-01-05 15:50:38 -05:00
Ken Moore
35a90406ec Oops, forgot to comment out the auth user/pass line from the log file (don't need to keep that around). 2016-01-05 15:12:07 -05:00
Ken Moore
858ed83611 Add in the REST authorization protocols so REST communications now get through to the backend systems if valid requests. 2016-01-05 15:11:01 -05:00
Ken Moore
c08a458127 Quick fix for the unauthorized return value for bad requests. 2016-01-05 14:46:00 -05:00
Ken Moore
a1ba1044ee Don't 'close' a socket after a TCP reply - instead just disconnect from the host after all data has been transmitted. 2016-01-05 14:17:46 -05:00
Ken Moore
a5fcddcbbe Separate out the reply systems within the websocket.[cpp/h] files, and ensure that we close the TCP socket after sending back a reply. 2016-01-05 13:46:55 -05:00
Kris Moore
ad8d88fc7c Fix a bug parsing the rest URI 2016-01-05 13:35:00 -05:00
Kris Moore
ea0bbad1f6 Merge branch 'master' of https://github.com/pcbsd/sysadm 2016-01-05 13:19:16 -05:00
Kris Moore
528c247607 Add LifePreserver API first list-cron call 2016-01-05 13:19:01 -05:00
Ken Moore
adda4e7931 Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-05 13:18:43 -05:00
Ken Moore
1c7dab4ab2 Fix a typo in the signal/slots for a tcp server. 2016-01-05 13:18:20 -05:00
Ken Moore
b1e451b385 Adjust the new sysadm/network function a bit - just add proper error code handling if nothing was performed. 2016-01-04 15:07:53 -05:00
Ken Moore
ace6c2ca4c Add a new subsystem to sysadm-server: the sysadm-network device information system.
To Access:
namespace="sysadm"
name="network"
args={"action" : "list-devices"}

Output arguments structure:
"<device name>" : {
 "ipv4" : <value>,
 "ipv6" : <value>,
 "netmask" : <value>,
 "description" : <value>,
 "MAC" : <value>,
 "status" : <value>,
 "is_active" : [true/false],
 "is_dhcp" : [true/false],
 "is_wireless" : [true/false]
}
2016-01-04 14:29:04 -05:00
Ken Moore
fdf06cac1e Clean up a bit more of the websocket class. 2016-01-04 13:44:58 -05:00
Ken Moore
7d53e59a1d Oops, forgot to turn off debug mode before committing. 2016-01-04 13:33:44 -05:00
Ken Moore
8d57413401 A few more updates to the input message parsing systems for the server: Ensure that both the namespace and the name of the input message are passed through to the backend parser/system (if authorized). 2016-01-04 13:30:49 -05:00
Ken Moore
87ab5f2a22 Fix the input argument parsing for sysadm-server. 2016-01-04 13:01:39 -05:00