forked from OpenWF/SpaceNinjaServer
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3fedc701f1 | |||
| ed596aa3f3 | 
@ -1,7 +1,7 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
import { getReflexiveAddress } from "../../services/configService.ts";
 | 
			
		||||
 | 
			
		||||
const hubController: RequestHandler = (_req, res) => {
 | 
			
		||||
    res.json("hub 127.0.0.1:6952");
 | 
			
		||||
export const hubController: RequestHandler = (req, res) => {
 | 
			
		||||
    const { myAddress } = getReflexiveAddress(req);
 | 
			
		||||
    res.json(`hub ${myAddress}:6952`);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export { hubController };
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
import type { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
import { config } from "../../services/configService.ts";
 | 
			
		||||
import { config, getReflexiveAddress } from "../../services/configService.ts";
 | 
			
		||||
import { buildConfig } from "../../services/buildConfigService.ts";
 | 
			
		||||
 | 
			
		||||
import { Account } from "../../models/loginModel.ts";
 | 
			
		||||
@ -20,21 +20,7 @@ export const loginController: RequestHandler = async (request, response) => {
 | 
			
		||||
            ? request.query.buildLabel.split(" ").join("+")
 | 
			
		||||
            : buildConfig.buildLabel;
 | 
			
		||||
 | 
			
		||||
    let myAddress: string;
 | 
			
		||||
    let myUrlBase: string = request.protocol + "://";
 | 
			
		||||
    if (request.host.indexOf("warframe.com") == -1) {
 | 
			
		||||
        // Client request was redirected cleanly, so we know it can reach us how it's reaching us now.
 | 
			
		||||
        myAddress = request.hostname;
 | 
			
		||||
        myUrlBase += request.host;
 | 
			
		||||
    } else {
 | 
			
		||||
        // Don't know how the client reached us, hoping the config does.
 | 
			
		||||
        myAddress = config.myAddress;
 | 
			
		||||
        myUrlBase += myAddress;
 | 
			
		||||
        const port: number = request.protocol == "http" ? config.httpPort || 80 : config.httpsPort || 443;
 | 
			
		||||
        if (port != (request.protocol == "http" ? 80 : 443)) {
 | 
			
		||||
            myUrlBase += ":" + port;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    const { myAddress, myUrlBase } = getReflexiveAddress(request);
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
        !account &&
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,7 @@ import path from "path";
 | 
			
		||||
import { repoDir } from "../helpers/pathHelper.ts";
 | 
			
		||||
import { args } from "../helpers/commandLineArguments.ts";
 | 
			
		||||
import { Inbox } from "../models/inboxModel.ts";
 | 
			
		||||
import type { Request } from "express";
 | 
			
		||||
 | 
			
		||||
export interface IConfig {
 | 
			
		||||
    mongodbUrl: string;
 | 
			
		||||
@ -165,3 +166,22 @@ export const syncConfigWithDatabase = (): void => {
 | 
			
		||||
        void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getReflexiveAddress = (request: Request): { myAddress: string; myUrlBase: string } => {
 | 
			
		||||
    let myAddress: string;
 | 
			
		||||
    let myUrlBase: string = request.protocol + "://";
 | 
			
		||||
    if (request.host.indexOf("warframe.com") == -1) {
 | 
			
		||||
        // Client request was redirected cleanly, so we know it can reach us how it's reaching us now.
 | 
			
		||||
        myAddress = request.hostname;
 | 
			
		||||
        myUrlBase += request.host;
 | 
			
		||||
    } else {
 | 
			
		||||
        // Don't know how the client reached us, hoping the config does.
 | 
			
		||||
        myAddress = config.myAddress;
 | 
			
		||||
        myUrlBase += myAddress;
 | 
			
		||||
        const port: number = request.protocol == "http" ? config.httpPort || 80 : config.httpsPort || 443;
 | 
			
		||||
        if (port != (request.protocol == "http" ? 80 : 443)) {
 | 
			
		||||
            myUrlBase += ":" + port;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return { myAddress, myUrlBase };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -2339,7 +2339,7 @@ function unlockFocusSchool(upgradeType) {
 | 
			
		||||
        $.post({
 | 
			
		||||
            url: "/api/focus.php?" + window.authz + "&op=5",
 | 
			
		||||
            contentType: "text/plain",
 | 
			
		||||
            data: "{}"
 | 
			
		||||
            data: JSON.stringify({ FocusType: null })
 | 
			
		||||
        }).done(function () {
 | 
			
		||||
            // Unlock the way now
 | 
			
		||||
            $.post({
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user