mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:44:35 +03:00
web interfaces: don't include version number in html, only return it after authentication
second round for issue #322
This commit is contained in:
@ -27,6 +27,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"sort"
|
||||
@ -279,6 +280,11 @@ func (w Admin) Logout(ctx context.Context) {
|
||||
xcheckf(ctx, err, "logout")
|
||||
}
|
||||
|
||||
// Version returns the version, goos and goarch.
|
||||
func (w Admin) Version(ctx context.Context) (version, goos, goarch string) {
|
||||
return moxvar.Version, runtime.GOOS, runtime.GOARCH
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
Errors []string
|
||||
Warnings []string
|
||||
|
@ -559,6 +559,14 @@ var api;
|
||||
const params = [];
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params);
|
||||
}
|
||||
// Version returns the version, goos and goarch.
|
||||
async Version() {
|
||||
const fn = "Version";
|
||||
const paramTypes = [];
|
||||
const returnTypes = [["string"], ["string"], ["string"]];
|
||||
const params = [];
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params);
|
||||
}
|
||||
// CheckDomain checks the configuration for the domain, such as MX, SMTP STARTTLS,
|
||||
// SPF, DKIM, DMARC, TLSRPT, MTASTS, autoconfig, autodiscover.
|
||||
async CheckDomain(domainName) {
|
||||
@ -1694,6 +1702,9 @@ var api;
|
||||
};
|
||||
})(api || (api = {}));
|
||||
// Javascript is generated from typescript, do not modify generated javascript because changes will be overwritten.
|
||||
let moxversion;
|
||||
let moxgoos;
|
||||
let moxgoarch;
|
||||
const login = async (reason) => {
|
||||
return new Promise((resolve, _) => {
|
||||
const origFocus = document.activeElement;
|
||||
@ -1833,7 +1844,7 @@ const crumbs = (...l) => {
|
||||
];
|
||||
};
|
||||
const errmsg = (err) => '' + (err.message || '(no error message)');
|
||||
const footer = dom.div(style({ marginTop: '6ex', opacity: 0.75 }), link('https://www.xmox.nl', 'mox'), ' ', moxversion, ' ', moxgoos, '/', moxgoarch, ', ', dom.a(attr.href('licenses.txt'), 'licenses'));
|
||||
const footer = () => dom.div(style({ marginTop: '6ex', opacity: 0.75 }), link('https://www.xmox.nl', 'mox'), ' ', moxversion, ' ', moxgoos, '/', moxgoarch, ', ', dom.a(attr.href('licenses.txt'), 'licenses'));
|
||||
const age = (date, future, nowSecs) => {
|
||||
if (!nowSecs) {
|
||||
nowSecs = new Date().getTime() / 1000;
|
||||
@ -1987,7 +1998,7 @@ const index = async () => {
|
||||
dom._kids(cidElem, cid);
|
||||
}, recvIDFieldset = dom.fieldset(dom.label('Received ID', attr.title('The ID in the Received header that was added during incoming delivery.')), ' ', recvID = dom.input(attr.required('')), ' ', dom.submitbutton('Lookup cid', attr.title('Logging about an incoming message includes an attribute "cid", a counter identifying the transaction related to delivery of the message. The ID in the received header is an encrypted cid, which this form decrypts, after which you can look it up in the logging.')), ' ', cidElem = dom.span()))),
|
||||
// todo: routing, globally, per domain and per account
|
||||
dom.br(), dom.h2('Configuration'), dom.div(dom.a('Routes', attr.href('#routes'))), dom.div(dom.a('Webserver', attr.href('#webserver'))), dom.div(dom.a('Files', attr.href('#config'))), dom.div(dom.a('Log levels', attr.href('#loglevels'))), footer);
|
||||
dom.br(), dom.h2('Configuration'), dom.div(dom.a('Routes', attr.href('#routes'))), dom.div(dom.a('Webserver', attr.href('#webserver'))), dom.div(dom.a('Files', attr.href('#config'))), dom.div(dom.a('Log levels', attr.href('#loglevels'))), footer());
|
||||
};
|
||||
const globalRoutes = async () => {
|
||||
const [transports, config] = await Promise.all([
|
||||
@ -4149,6 +4160,7 @@ const webserver = async () => {
|
||||
};
|
||||
const init = async () => {
|
||||
let curhash;
|
||||
[moxversion, moxgoos, moxgoarch] = await client.Version();
|
||||
const hashChange = async () => {
|
||||
if (curhash === window.location.hash) {
|
||||
return;
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
// From HTML.
|
||||
declare let page: HTMLElement
|
||||
declare let moxversion: string
|
||||
declare let moxgoos: string
|
||||
declare let moxgoarch: string
|
||||
// From customization script.
|
||||
declare let moxBeforeDisplay: (webmailroot: HTMLElement) => void
|
||||
|
||||
let moxversion: string
|
||||
let moxgoos: string
|
||||
let moxgoarch: string
|
||||
|
||||
const login = async (reason: string) => {
|
||||
return new Promise<string>((resolve: (v: string) => void, _) => {
|
||||
const origFocus = document.activeElement
|
||||
@ -191,14 +192,15 @@ const crumbs = (...l: ({text: string, path: string} | string)[]) => {
|
||||
|
||||
const errmsg = (err: unknown) => ''+((err as any).message || '(no error message)')
|
||||
|
||||
const footer = dom.div(
|
||||
style({marginTop: '6ex', opacity: 0.75}),
|
||||
link('https://www.xmox.nl', 'mox'),
|
||||
' ',
|
||||
moxversion, ' ',
|
||||
moxgoos, '/', moxgoarch,
|
||||
', ', dom.a(attr.href('licenses.txt'), 'licenses')
|
||||
)
|
||||
const footer = () =>
|
||||
dom.div(
|
||||
style({marginTop: '6ex', opacity: 0.75}),
|
||||
link('https://www.xmox.nl', 'mox'),
|
||||
' ',
|
||||
moxversion, ' ',
|
||||
moxgoos, '/', moxgoarch,
|
||||
', ', dom.a(attr.href('licenses.txt'), 'licenses')
|
||||
)
|
||||
|
||||
const age = (date: Date, future: boolean, nowSecs: number) => {
|
||||
if (!nowSecs) {
|
||||
@ -438,7 +440,7 @@ const index = async () => {
|
||||
dom.div(dom.a('Webserver', attr.href('#webserver'))),
|
||||
dom.div(dom.a('Files', attr.href('#config'))),
|
||||
dom.div(dom.a('Log levels', attr.href('#loglevels'))),
|
||||
footer,
|
||||
footer(),
|
||||
)
|
||||
}
|
||||
|
||||
@ -4249,7 +4251,7 @@ const hooksList = async () => {
|
||||
style({textAlign: 'right'}), // Less content shifting while rendering.
|
||||
'Sort ',
|
||||
sortElem=dom.select(
|
||||
attr.form('hooksfilter'),
|
||||
attr.form('hooksfilter'),
|
||||
function change() {
|
||||
filterForm.requestSubmit()
|
||||
},
|
||||
@ -5342,6 +5344,8 @@ const webserver = async () => {
|
||||
const init = async () => {
|
||||
let curhash: string | undefined
|
||||
|
||||
[moxversion, moxgoos, moxgoarch] = await client.Version()
|
||||
|
||||
const hashChange = async () => {
|
||||
if (curhash === window.location.hash) {
|
||||
return
|
||||
|
@ -47,6 +47,31 @@
|
||||
"Params": [],
|
||||
"Returns": []
|
||||
},
|
||||
{
|
||||
"Name": "Version",
|
||||
"Docs": "Version returns the version, goos and goarch.",
|
||||
"Params": [],
|
||||
"Returns": [
|
||||
{
|
||||
"Name": "version",
|
||||
"Typewords": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "goos",
|
||||
"Typewords": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "goarch",
|
||||
"Typewords": [
|
||||
"string"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "CheckDomain",
|
||||
"Docs": "CheckDomain checks the configuration for the domain, such as MX, SMTP STARTTLS,\nSPF, DKIM, DMARC, TLSRPT, MTASTS, autoconfig, autodiscover.",
|
||||
|
@ -1457,6 +1457,15 @@ export class Client {
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params) as void
|
||||
}
|
||||
|
||||
// Version returns the version, goos and goarch.
|
||||
async Version(): Promise<[string, string, string]> {
|
||||
const fn: string = "Version"
|
||||
const paramTypes: string[][] = []
|
||||
const returnTypes: string[][] = [["string"],["string"],["string"]]
|
||||
const params: any[] = []
|
||||
return await _sherpaCall(this.baseURL, this.authState, { ...this.options }, paramTypes, returnTypes, fn, params) as [string, string, string]
|
||||
}
|
||||
|
||||
// CheckDomain checks the configuration for the domain, such as MX, SMTP STARTTLS,
|
||||
// SPF, DKIM, DMARC, TLSRPT, MTASTS, autoconfig, autodiscover.
|
||||
async CheckDomain(domainName: string): Promise<CheckResult> {
|
||||
|
Reference in New Issue
Block a user