This commit is contained in:
j3d1 2024-02-24 01:50:59 +01:00
parent a85c3c3296
commit c7c91f87ba
4 changed files with 51 additions and 28 deletions

View file

@ -35,7 +35,7 @@ class FallBackResolver {
const key = domain + ':' + type; const key = domain + ':' + type;
if (key in this._cache && this._cache[key].time > Date.now() - 1000 * 60 * 60) { if (key in this._cache && this._cache[key].time > Date.now() - 1000 * 60 * 60) {
const age_seconds = Math.ceil(Date.now() / 1000 - this._cache[key].time / 1000); const age_seconds = Math.ceil(Date.now() / 1000 - this._cache[key].time / 1000);
console.log('cache hit', key, this._cache[key].ttl - age_seconds); //console.log('cache hit', key, this._cache[key].ttl - age_seconds);
return [this._cache[key].data]; return [this._cache[key].data];
} }
const result = await query( const result = await query(
@ -48,7 +48,7 @@ class FallBackResolver {
const first = result.answers[0]; const first = result.answers[0];
this._cache[key] = {time: Date.now(), ...first}; // TODO hadle multiple answers this._cache[key] = {time: Date.now(), ...first}; // TODO hadle multiple answers
localStorage.setItem('dns-cache', JSON.stringify(this._cache)); localStorage.setItem('dns-cache', JSON.stringify(this._cache));
console.log('cache miss', key, first.ttl); //console.log('cache miss', key, first.ttl);
return [first.data]; return [first.data];
} }
} }

View file

@ -130,16 +130,12 @@ export default createStore({
}, },
async lookupServer({state}, {username}) { async lookupServer({state}, {username}) {
const domain = username.split('@')[1] const domain = username.split('@')[1]
if (domain === 'example.eleon')
return ['10.23.42.186:8000'];
if (domain === 'localhost') if (domain === 'localhost')
return ['127.0.0.1:8000']; return ['localhost:5173'];
if (domain === 'example.com') if (domain === 'example.com')
return ['10.23.42.128:8000', '10.23.42.128:8000']; return ['localhost:5173'];
if (domain === 'example.jedi') if (domain === 'example.jedi')
return ['10.23.42.128:8000']; return ['localhost:5173'];
if (domain === 'example2.com')
return ['10.23.42.128:9000'];
const request = '_toolshed-server._tcp.' + domain + '.' const request = '_toolshed-server._tcp.' + domain + '.'
return await state.resolver.query(request, 'SRV').then( return await state.resolver.query(request, 'SRV').then(
(result) => result.map( (result) => result.map(

View file

@ -20,9 +20,10 @@
<div class="card-body"> <div class="card-body">
<div class="m-sm-4"> <div class="m-sm-4">
<form role="form" method="post" @submit.prevent="do_register"> <form role="form" method="post" @submit.prevent="do_register">
<div :class="errors.username||errors.domain?['mb-3','is-invalid']:['mb-3']"> <div class="mb-3">
<label class="form-label">Username</label> <label class="form-label">Username</label>
<div class="input-group"> <div class="input-group"
:class="errors.username||errors.domain?['is-invalid']:[]">
<input class="form-control form-control-lg" <input class="form-control form-control-lg"
type="text" v-model="form.username" id="validationCustomUsername" type="text" v-model="form.username" id="validationCustomUsername"
placeholder="Enter your username" required/> placeholder="Enter your username" required/>
@ -41,7 +42,7 @@
</div> </div>
</div> </div>
<div :class="errors.email?['mb-3','is-invalid']:['mb-3']"> <div class="mb-3">
<label class="form-label">Email</label> <label class="form-label">Email</label>
<input class="form-control form-control-lg" type="email" <input class="form-control form-control-lg" type="email"
:class="errors.email?['is-invalid']:[]" :class="errors.email?['is-invalid']:[]"
@ -49,7 +50,7 @@
<div class="invalid-feedback">{{ errors.email }}</div> <div class="invalid-feedback">{{ errors.email }}</div>
</div> </div>
<div :class="errors.password?['mb-3','is-invalid']:['mb-3']"> <div class="mb-3">
<label class="form-label">Password</label> <label class="form-label">Password</label>
<input class="form-control form-control-lg" type="password" <input class="form-control form-control-lg" type="password"
:class="errors.password?['is-invalid']:[]" :class="errors.password?['is-invalid']:[]"
@ -57,7 +58,7 @@
<div class="invalid-feedback">{{ errors.password }}</div> <div class="invalid-feedback">{{ errors.password }}</div>
</div> </div>
<div :class="errors.password2?['mb-3','is-invalid']:['mb-3']"> <div class="mb-3">
<label class="form-label">Password Check</label> <label class="form-label">Password Check</label>
<input class="form-control form-control-lg" type="password" <input class="form-control form-control-lg" type="password"
:class="errors.password2?['is-invalid']:[]" :class="errors.password2?['is-invalid']:[]"

View file

@ -25,26 +25,52 @@ export default defineConfig({
+ ' img-src \'self\' https://* data:;' + ' img-src \'self\' https://* data:;'
+ ' connect-src * data:', // TODO: change * to https://* for production + ' connect-src * data:', // TODO: change * to https://* for production
}, },
/*https: { https: {
key: fs.readFileSync('privkey.pem'), key: fs.readFileSync('.local/privkey.pem'),
cert: fs.readFileSync('fullchain.pem') cert: fs.readFileSync('.local/fullchain.pem')
},*/ },
proxy: { proxy: {
'^/api/': { '^/api/': {
target: "https://toolshed.j3d1.de:8000/", target: "http://127.0.0.1:8000/",
headers: {
'Host': 'localhost:5173',
'Origin': 'https://localhost:5173',
'X-Forwarded-Host': 'localhost:5173',
'X-Forwarded-Proto': 'https',
}
}, },
'^/auth/': { '^/auth/': {
target: "https://toolshed.j3d1.de:8000/", target: "http://127.0.0.1:8000/",
secure: false, headers: {
}, 'Host': 'localhost:5173',
'^/docs/': { 'Origin': 'https://localhost:5173',
target: "https://toolshed.j3d1.de:8000/", 'X-Forwarded-Host': 'localhost:5173',
}, 'X-Forwarded-Proto': 'https',
'^/static/': { }
target: "https://toolshed.j3d1.de:8000/", // target: "https://toolshed.j3d1.de:8000/",
// secure: false,
// },
// '^/docs/': {
// target: "https://toolshed.j3d1.de:8000/",
// },
// '^/static/': {
// target: "https://toolshed.j3d1.de:8000/",
//>>>>>>> busti/proto/frontend
}, },
'^/media/': { '^/media/': {
target: "https://toolshed.j3d1.de:8000/", target: "http://127.0.0.1:8000/",
headers: {
'Host': 'localhost:5173',
'Origin': 'https://localhost:5173',
'X-Forwarded-Host': 'localhost:5173',
'X-Forwarded-Proto': 'https',
}
},
'^/docs/': {
target: "http://127.0.0.1:8000/",
},
'^/static/': {
target: "http://127.0.0.1:8000/",
}, },
'^/wiki/': { '^/wiki/': {
target: "http://127.0.0.1:8080/", target: "http://127.0.0.1:8080/",