asvow / luci-app-tailscale

LuCI support for tailscale
GNU General Public License v3.0
134 stars 23 forks source link

Add luci-app-tailscale to Official OpenWRT Package #2

Closed animegasan closed 6 months ago

animegasan commented 8 months ago

Hello, I am very impressed with this project, because it can add another option to remote OpenWRT with local network like ZeroTier!

There is input from me, why not just add a logs page to read all processes from tailscale?

References can be seen on the following page https://github.com/openwrt/luci/blob/master/applications/luci-app-cloudflared/htdocs/luci-static/resources/view/cloudflared/log.js

And try making a pull request to Luci OpenWRT to make it an official package. Thank You!

animegasan commented 8 months ago

image

    load: function () {
        poll.add(function() {
            return fs.exec('/sbin/logread', ['-e', 'tailscale'])
                .then(function (res) {
                    if (res.code === 0) {
                        var statusMappings = {
                            'daemon.err': { status: 'Error', startIndex: 9 },
                            'daemon.notice': { status: 'Info', startIndex: 10 }
                        };
                        var logs = res.stdout.split('\n').map(function(log) {
                            var logParts = log.split(' ');
                            if (logParts.length >= 6) {
                                var formattedTime = logParts[1] + ' ' + logParts[2] + ' - ' + logParts[3];
                                var status = logParts[5];
                                var mapping = statusMappings[status] || { status: status, startIndex: 9 };
                                status = mapping.status;
                                var startIndex = mapping.startIndex;
                                var message = logParts.slice(startIndex).join(' ');
                                return formattedTime + ' [ ' + status + ' ] - ' + message;
                            } else {
                                return '';
                            }
                        }).filter(Boolean).join('\n');
                        var view = document.getElementById('syslog');
                        view.innerHTML = logs;
                        return view;
                    } else {
                        throw new Error(res.stdout + ' ' + res.stderr);
                    }
                })
        });
    },
zzduci commented 7 months ago

Hello, I am very impressed with this project, because it can add another option to remote OpenWRT with local network like ZeroTier!

There is input from me, why not just add a logs page to read all processes from tailscale?

References can be seen on the following page https://github.com/openwrt/luci/blob/master/applications/luci-app-cloudflared/htdocs/luci-static/resources/view/cloudflared/log.js

And try making a pull request to Luci OpenWRT to make it an official package. Thank You!

it is a good idea