Last minute updates

This commit is contained in:
Cam 2024-03-12 11:18:31 -05:00
parent d4a883b9ba
commit 6c905538db
No known key found for this signature in database
GPG Key ID: 367B7C7EBD84A8BD
7 changed files with 371 additions and 384 deletions

View File

@ -19,21 +19,22 @@ program
.description("command to host content to be pastedfrom'd")
.action(() => __awaiter(void 0, void 0, void 0, function* () {
let root = zrok.Load();
yield zrok.init(root);
//await ziti.init( root.env.ZitiIdentity ).catch(( err: Error ) => { console.error(err); return process.exit(1) });
ziti.setLogLevel(10);
let shr = yield zrok.CreateShare(root, new zrok.ShareRequest(zrok.TCP_TUNNEL_BACKEND_MODE, zrok.PUBLIC_SHARE_MODE, "pastebin", ["public"]));
console.log("setting up app");
let service = "ns5ix2brb61f";
console.log("attempting to bind to service: " + service);
let app = ziti.express(express, service);
console.log("attempting to bind to service: " + shr.Token);
let app = ziti.express(express, shr.Token);
console.log("after setting up app");
app.get('/', function (_, res) {
res.write("Test");
});
console.log("after setting up get");
//app.listen(undefined, () => {
// console.log(`Example app listening!`)
//})
app.listen(undefined, () => {
console.log(`Example app listening!`);
});
console.log("after listen");
zrok.DeleteShare(root, shr);
}));
@ -41,9 +42,20 @@ program
.command('pastefrom <shrToken>')
.version("1.0.0")
.description("command to paste content from coptyo")
.action((shrToken) => {
.action((shrToken) => __awaiter(void 0, void 0, void 0, function* () {
//ziti.setLogLevel(10)
console.log('pastefrom command called', shrToken);
let root = zrok.Load();
yield zrok.init(root).catch((err) => {
console.log(err);
});
let acc = yield zrok.CreateAccess(root, new zrok.AccessRequest(shrToken));
console.log("about to dial");
zrok.dialer(root, shrToken, (data) => {
console.log("in callback");
console.log(data.toString());
});
}));
program.parse(process.argv);
const options = program.opts();
//# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACzC,MAAM,IA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G,CAAC,CAAA;IAClB,CAAC,CAAC,CAAC;IACH,IAAI,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAS,EAAE,EAAE;QACxC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC"}

File diff suppressed because it is too large Load Diff

View File

@ -12,21 +12,22 @@ program
.description("command to host content to be pastedfrom'd")
.action(async () => {
let root = zrok.Load()
await zrok.init(root);
//await ziti.init( root.env.ZitiIdentity ).catch(( err: Error ) => { console.error(err); return process.exit(1) });
ziti.setLogLevel(10)
let shr = await zrok.CreateShare(root, new zrok.ShareRequest(zrok.TCP_TUNNEL_BACKEND_MODE, zrok.PUBLIC_SHARE_MODE, "pastebin", ["public"]));
console.log("setting up app")
let service = "ns5ix2brb61f"
console.log("attempting to bind to service: "+ service)
let app = ziti.express( express, service );
console.log("attempting to bind to service: "+ shr.Token)
let app = ziti.express( express, shr.Token );
console.log("after setting up app")
app.get('/',function(_: Request,res: any){
res.write("Test")
});
console.log("after setting up get")
//app.listen(undefined, () => {
// console.log(`Example app listening!`)
//})
app.listen(undefined, () => {
console.log(`Example app listening!`)
})
console.log("after listen")
zrok.DeleteShare(root, shr);
});
@ -35,8 +36,20 @@ program
.command('pastefrom <shrToken>')
.version("1.0.0")
.description("command to paste content from coptyo")
.action((shrToken: string) => {
.action(async (shrToken: string) => {
//ziti.setLogLevel(10)
console.log('pastefrom command called', shrToken);
let root = zrok.Load();
await zrok.init(root).catch((err: any) => {
console.log(err)
});
let acc = await zrok.CreateAccess(root, new zrok.AccessRequest(shrToken))
console.log("about to dial")
zrok.dialer(root, shrToken, (data: any) => {
console.log("in callback")
console.log(data.toString())
});
});
program.parse(process.argv)

View File

@ -116,11 +116,11 @@ export class Root {
return "public"
}
private EnvironmentIdentityName(): string {
public EnvironmentIdentityName(): string {
return "environment"
}
private ZitiIdentityName(name: string): string {
public ZitiIdentityNamed(name: string): string {
return identityFile(name)
}
}

View File

@ -1,5 +1,7 @@
//module.exports = require("./environment");
export * from "./zrok/model"
export * from "./zrok/share"
export * from "./zrok/access"
export * from "./zrok/zrok"
export * from "./environment/dirs"
export * from "./environment/root"

View File

@ -7,5 +7,9 @@ export function express(shrToken: string): Express.Application {
}
export async function init(root: Root): Promise<any> {
return ziti.init(root.env.ZitiIdentity)
return ziti.init(root.ZitiIdentityNamed(root.EnvironmentIdentityName()))
}
export function dialer(root: Root, shrToken: string, callback: any): ziti.dialer {
ziti.listen(shrToken, false, undefined, callback)
}