-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'revenz:master' into master
- Loading branch information
Showing
15 changed files
with
283 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"Name": "Coder", | ||
"Icon": "coder.png", | ||
"TestFunction":true, | ||
"Interval": 10, | ||
"Info":{ | ||
"Authors": ["mindofbeholder"], | ||
"AppUrl":"https://coder.com" | ||
}, | ||
"Properties": [ | ||
{ | ||
"Name": "Token", | ||
"Id": "token", | ||
"Type": "string", | ||
"Help" : "Found at Account -> Tokens" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
class Coder { | ||
|
||
cleanUrl(args) | ||
{ | ||
if(args.url.endsWith('/')) | ||
return args.url.substring(0, args.url.length - 1); | ||
else | ||
return args.url | ||
} | ||
|
||
fetchWorkspaces(args) { | ||
let cleanedUrl = this.cleanUrl(args) | ||
|
||
let allWorkspacesData = args.fetch({ | ||
url: cleanedUrl + "/api/v2/workspaces", | ||
method: "GET", | ||
headers: { | ||
'Coder-Session-Token': args.properties['token'], | ||
'Accept': 'application/json' | ||
} | ||
}).data; | ||
|
||
let totalWorkspaces = allWorkspacesData.count; | ||
|
||
let runningWorkspacesData = args.fetch({ | ||
url: cleanedUrl + "/api/v2/workspaces?q=status:running", | ||
method: "GET", | ||
headers: { | ||
'Coder-Session-Token': args.properties['token'], | ||
'Accept': 'application/json' | ||
} | ||
}).data; | ||
|
||
let runningWorkspaces = runningWorkspacesData.count; | ||
|
||
return { "total": totalWorkspaces, "active": runningWorkspaces } | ||
} | ||
|
||
status(args) { | ||
|
||
let results = this.fetchWorkspaces(args) | ||
|
||
return args.liveStats([ | ||
['Active Workspaces', results.active], | ||
['Total Workspaces', results.total] | ||
]); | ||
} | ||
|
||
test(args) { | ||
|
||
if (!args.properties || !args.properties['token']) { | ||
args.log("No API Key"); | ||
return false | ||
} | ||
|
||
let results = args.fetch({ | ||
url: this.cleanUrl(args) + "/api/v2/workspaces", | ||
method: "GET", | ||
headers: { | ||
'Coder-Session-Token': args.properties['token'], | ||
'Accept': 'application/json' | ||
} | ||
}); | ||
|
||
if (results.status == 200) { | ||
return true | ||
} else { | ||
args.log(JSON.stringify(results)); | ||
return false | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace Fenrus.Models; | ||
|
||
/// <summary> | ||
/// Configuration object that maps to the ReverseProxySettings section in appsettings.json | ||
/// </summary> | ||
public class ReverseProxySettings | ||
{ | ||
/// <summary> | ||
/// If the request headers should be printed to the console when being redirected to the | ||
/// authentication provider. | ||
/// </summary> | ||
public bool DebugPrintRequestHeaders { get; set; } | ||
|
||
/// <summary> | ||
/// If the forwarded headers should be used. | ||
/// </summary> | ||
public bool UseForwardedHeaders { get; set; } | ||
|
||
/// <summary> | ||
/// The IP-addresses of known proxies. | ||
/// </summary> | ||
public string[] KnownProxies { get; set; } = Array.Empty<string>(); | ||
|
||
/// <summary> | ||
/// The IP-address specification of a known network in IPv4 format | ||
/// For example: 192.168.2.0/24, which will allow all IP-addresses from | ||
/// 192.168.2.1 - 192.168.2.254 | ||
/// </summary> | ||
public KnownNetwork KnownIpv4Network { get; set; } = new(); | ||
|
||
/// <summary> | ||
/// The IP-address specification of a known network in IPv6 format | ||
/// For example: 2001:db8::/32, which will allow all IP-addresses from | ||
/// 2001:db8:0:0:0:0:0:0 - 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff | ||
/// </summary> | ||
public KnownNetwork KnownIpv6Network { get; set; } = new(); | ||
|
||
} | ||
|
||
public class KnownNetwork | ||
{ | ||
/// <summary> | ||
/// If the known network should be added to the list of known networks. | ||
/// </summary> | ||
public bool Enabled { get; set; } | ||
|
||
/// <summary> | ||
/// The IP-address of the known network. | ||
/// For example: 192.168.2.0 or 2001:db8:: | ||
/// </summary> | ||
public string IpAddress { get; set; } | ||
|
||
/// <summary> | ||
/// The prefix length of the known network. For example: 24 | ||
/// </summary> | ||
public int PrefixLength { get; set; } | ||
} |
Oops, something went wrong.