Skip to content

Commit a06bc54

Browse files
committed
Various fixes to get manx back to working order
1 parent 8adc3c8 commit a06bc54

File tree

3 files changed

+27
-66
lines changed

3 files changed

+27
-66
lines changed

app/c_session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ class Session(BaseObject):
77
def unique(self):
88
return self.hash('%s' % self.paw)
99

10-
def __init__(self, id, paw, connection):
10+
def __init__(self, id, paw, reader, writer):
1111
super().__init__()
1212
self.id = id
1313
self.paw = paw
14-
self.connection = connection
14+
self.reader = reader
15+
self.writer = writer
1516

1617
def store(self, ram):
1718
existing = self.retrieve(ram['sessions'], self.unique)

gui/views/manx.vue

Lines changed: 12 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import { storeToRefs } from "pinia";
55
const $api = inject("$api");
66
77
onMounted(async () => {});
8+
89
</script>
910

1011
<script>
1112
import { toast } from "bulma-toast";
1213
import { useCoreStore } from "@/stores/coreStore";
1314
import { mapState } from "pinia";
15+
import { loadCommand, setCommand } from '@/../../manx/static/js/terminal.js'
16+
1417
export default {
1518
inject: ["$api"],
1619
data() {
@@ -37,9 +40,9 @@ export default {
3740
},
3841
}
3942
},
40-
created() {
43+
mounted() {
4144
this.initPage();
42-
},
45+
},
4346
computed: {
4447
...mapState(useCoreStore, ["mainConfig"]),
4548
},
@@ -50,47 +53,18 @@ export default {
5053
},
5154
methods: {
5255
async initPage() {
53-
let termScript = document.createElement("script");
54-
termScript.setAttribute(
55-
"src",
56-
"/manx/js/terminal.js"
57-
);
58-
termScript.setAttribute(
59-
"type",
60-
"module"
61-
);
62-
if (!import.meta.env.PROD) {
63-
termScript.setAttribute(
64-
"src",
65-
"http://localhost:8888/manx/js/terminal.js"
66-
);
67-
}
68-
document.head.appendChild(termScript);
69-
this.$api.get("/plugin/manx/sessions").then((sessions) => {
70-
this.sessions = sessions.data.sessions;
71-
}).catch((error) => {
72-
toast({message: "Error loading sessions", type: "is-danger", dismissible: true, pauseOnHover: true, duration: 2000})
73-
console.error(error);
74-
});
56+
loadCommand(this.$api);
57+
58+
this.refreshManx();
7559
setInterval(async () => {
76-
if (!document.querySelector('.xterm-cursor-layer') && window.loadManxTerm) {
77-
window.loadManxTerm();
78-
}
7960
this.refreshManx();
8061
}, "3000");
81-
// while (this.$refs.header) {
82-
// if (!document.querySelector('.xterm-cursor-layer') && window.loadManxTerm) {
83-
// window.loadManxTerm();
84-
// }
85-
// await sleep(3000);
86-
// this.refreshManx();
87-
// }
8862
},
8963
9064
refreshManx() {
91-
this.$api.post('/plugin/manx/sessions').then((sessions) => {
65+
this.$api.get('/plugin/manx/sessions').then((sessions) => {
9266
// Join new manx agents in array, and assign default platform and executors if DNE
93-
sessions = sessions.data;
67+
sessions = sessions.data.sessions;
9468
this.sessions = this.sessions.concat(sessions.map((s) => ({ ...s, platform: s.platform || this.DEFAULT_PLATFORM, executors: s.executors || [this.DEFAULT_EXECUTORS] })).filter((s) => !this.sessionIDs.includes(s.id)));
9569
}).catch((error) => {
9670
toast({message: "Error refreshing manx", type: "is-danger", dismissible: true, pauseOnHover: true, duration: 2000})
@@ -117,7 +91,7 @@ export default {
11791
});
11892
}
11993
};
120-
this.$api.post("/api/rest", { paw: this.selectedSessionID.info}).then((res) => {
94+
this.$api.post("/plugin/manx/ability", { paw: this.selectedSession.info}).then((res) => {
12195
getUniqueAbilities(this, res.data);
12296
}).catch((error) => {
12397
toast({message: "Error getting tactics", type: "is-danger", dismissible: true, pauseOnHover: true, duration: 2000})
@@ -148,10 +122,9 @@ export default {
148122
getProcedure() {
149123
const getCommands = (self, data) => {
150124
if (data && data.length > 0) {
151-
data = JSON.parse(data);
152125
data.forEach((ability) => {
153126
const executor = ability.executors.find((e) => e.platform === self.selectedSession.platform && e.name === self.selectedSession.executors[0]);
154-
self.terminalCommand = executor ? executor.command : '';
127+
setCommand(executor ? executor.command : '');
155128
});
156129
} else {
157130
toast({message: "No ability available for this agents platform and executor combination", type: "is-warning", dismissible: true, pauseOnHover: true, duration: 2000})

static/js/terminal.js

Lines changed: 12 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)