mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-21 00:45:49 +08:00
getifaddrs fix
This commit is contained in:
Binary file not shown.
BIN
assets/patch.tar.gz
Normal file
BIN
assets/patch.tar.gz
Normal file
Binary file not shown.
243
extra/getifaddrs_bridge/getifaddrs_bridge_client_lib.c
Normal file
243
extra/getifaddrs_bridge/getifaddrs_bridge_client_lib.c
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
// getifaddrs_bridge_client_lib.c -- This file is part of tiny_computer.
|
||||||
|
|
||||||
|
// Copyright (C) 2023 Caten Hu
|
||||||
|
|
||||||
|
// Tiny Computer is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License,
|
||||||
|
// or any later version.
|
||||||
|
|
||||||
|
// Tiny Computer is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
// See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
/* this file is mainly generated by Bing */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 1024 // 定义缓冲区大小
|
||||||
|
|
||||||
|
// 定义一个反序列化函数,将字节数组转换为ifaddrs结构体
|
||||||
|
int TINY_deserialize_ifaddrs(char *buf, int size, struct ifaddrs **ifap) {
|
||||||
|
int len = 0; // 记录已经读取的字节数
|
||||||
|
struct ifaddrs *head = NULL; // 链表头指针
|
||||||
|
struct ifaddrs *tail = NULL; // 链表尾指针
|
||||||
|
while (len < size) {
|
||||||
|
// 为当前接口分配内存
|
||||||
|
struct ifaddrs *ifa = (struct ifaddrs *)malloc(sizeof(struct ifaddrs));
|
||||||
|
if (ifa == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
// 读取接口名称
|
||||||
|
int namelen = strlen(buf + len) + 1; // 包括结束符
|
||||||
|
if (len + namelen > size) break; // 缓冲区不足
|
||||||
|
ifa->ifa_name = (char *)malloc(namelen); // 为名称分配内存
|
||||||
|
if (ifa->ifa_name == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
free(ifa);
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
memcpy(ifa->ifa_name, buf + len, namelen); // 复制名称
|
||||||
|
len += namelen;
|
||||||
|
// 读取接口标志
|
||||||
|
if (len + sizeof(unsigned int) > size) break; // 缓冲区不足
|
||||||
|
memcpy(&ifa->ifa_flags, buf + len, sizeof(unsigned int)); // 复制标志
|
||||||
|
len += sizeof(unsigned int);
|
||||||
|
// 读取接口地址
|
||||||
|
if (buf[len] != '\0') {
|
||||||
|
// 如果有地址
|
||||||
|
int addrlen = sizeof(struct sockaddr); // 地址结构体长度
|
||||||
|
if (len + addrlen > size) break; // 缓冲区不足
|
||||||
|
ifa->ifa_addr = (struct sockaddr *)malloc(addrlen); // 为地址分配内存
|
||||||
|
if (ifa->ifa_addr == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
free(ifa->ifa_name);
|
||||||
|
free(ifa);
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
memcpy(ifa->ifa_addr, buf + len, addrlen); // 复制地址
|
||||||
|
len += addrlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有地址,跳过一个空字节
|
||||||
|
ifa->ifa_addr = NULL;
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 读取接口掩码
|
||||||
|
if (buf[len] != '\0') {
|
||||||
|
// 如果有掩码
|
||||||
|
int masklen = sizeof(struct sockaddr); // 掩码结构体长度
|
||||||
|
if (len + masklen > size) break; // 缓冲区不足
|
||||||
|
ifa->ifa_netmask = (struct sockaddr *)malloc(masklen); // 为掩码分配内存
|
||||||
|
if (ifa->ifa_netmask == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
free(ifa->ifa_addr);
|
||||||
|
free(ifa->ifa_name);
|
||||||
|
free(ifa);
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
memcpy(ifa->ifa_netmask, buf + len, masklen); // 复制
|
||||||
|
len += masklen;
|
||||||
|
} else {
|
||||||
|
// 如果没有掩码,跳过一个空字节
|
||||||
|
ifa->ifa_netmask = NULL;
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 读取接口广播地址或点对点地址
|
||||||
|
if (ifa->ifa_flags & IFF_BROADCAST) {
|
||||||
|
// 如果有广播地址
|
||||||
|
if (buf[len] != '\0') {
|
||||||
|
// 如果有广播地址
|
||||||
|
int broadlen = sizeof(struct sockaddr); // 广播地址结构体长度
|
||||||
|
if (len + broadlen > size) break; // 缓冲区不足
|
||||||
|
ifa->ifa_broadaddr = (struct sockaddr *)malloc(broadlen); // 为广播地址分配内存
|
||||||
|
if (ifa->ifa_broadaddr == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
free(ifa->ifa_netmask);
|
||||||
|
free(ifa->ifa_addr);
|
||||||
|
free(ifa->ifa_name);
|
||||||
|
free(ifa);
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
memcpy(ifa->ifa_broadaddr, buf + len, broadlen); // 复制广播地址
|
||||||
|
len += broadlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有广播地址,跳过一个空字节
|
||||||
|
ifa->ifa_broadaddr = NULL;
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
} else if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||||
|
// 如果有点对点地址
|
||||||
|
if (buf[len] != '\0') {
|
||||||
|
// 如果有点对点地址
|
||||||
|
int dstlen = sizeof(struct sockaddr); // 点对点地址结构体长度
|
||||||
|
if (len + dstlen > size) break; // 缓冲区不足
|
||||||
|
ifa->ifa_dstaddr = (struct sockaddr *)malloc(dstlen); // 为点对点地址分配内存
|
||||||
|
if (ifa->ifa_dstaddr == NULL) {
|
||||||
|
// 分配失败,释放已分配的内存
|
||||||
|
free(ifa->ifa_netmask);
|
||||||
|
free(ifa->ifa_addr);
|
||||||
|
free(ifa->ifa_name);
|
||||||
|
free(ifa);
|
||||||
|
freeifaddrs(head);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
memcpy(ifa->ifa_dstaddr, buf + len, dstlen); // 复制点对点地址
|
||||||
|
len += dstlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有点对点地址,跳过一个空字节
|
||||||
|
ifa->ifa_dstaddr = NULL;
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有广播地址或点对点地址,跳过两个空字节
|
||||||
|
ifa->ifa_broadaddr = NULL;
|
||||||
|
ifa->ifa_dstaddr = NULL;
|
||||||
|
len += 2;
|
||||||
|
}
|
||||||
|
// 读取接口数据
|
||||||
|
if (buf[len] != '\0') {
|
||||||
|
// 如果有数据
|
||||||
|
// TODO: 根据不同的地址族,读取不同的数据
|
||||||
|
// 这里暂时省略,只跳过一个空字节
|
||||||
|
ifa->ifa_data = NULL;
|
||||||
|
len += 1;
|
||||||
|
} else {
|
||||||
|
// 如果没有数据,跳过一个空字节
|
||||||
|
ifa->ifa_data = NULL;
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 将当前接口插入链表
|
||||||
|
ifa->ifa_next = NULL;
|
||||||
|
if (head == NULL) {
|
||||||
|
// 如果是第一个接口,设置头指针
|
||||||
|
head = ifa;
|
||||||
|
} else {
|
||||||
|
// 如果不是第一个接口,设置尾指针的下一个指针
|
||||||
|
tail->ifa_next = ifa;
|
||||||
|
}
|
||||||
|
// 更新尾指针
|
||||||
|
tail = ifa;
|
||||||
|
}
|
||||||
|
*ifap = head; // 返回链表头指针
|
||||||
|
return len; // 返回读取的总字节数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义一个发送信号的函数,向服务器发送一个信号
|
||||||
|
int TINY_send_signal(int sockfd) {
|
||||||
|
char sig = 'S'; // 定义信号为一个字符S
|
||||||
|
int n = write(sockfd, &sig, 1); // 向套接字写入一个字节
|
||||||
|
if (n < 0) {
|
||||||
|
perror("write");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
return 0; // 返回成功
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义一个接收数据的函数,从服务器接收数据并反序列化
|
||||||
|
int TINY_receive_data(int sockfd, struct ifaddrs **ifap) {
|
||||||
|
char buf[BUFSIZE]; // 定义缓冲区
|
||||||
|
int n = read(sockfd, buf, BUFSIZE); // 从套接字读取数据
|
||||||
|
if (n < 0) {
|
||||||
|
perror("read");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
int len = TINY_deserialize_ifaddrs(buf, n, ifap); // 反序列化数据
|
||||||
|
if (len < 0) {
|
||||||
|
fprintf(stderr, "deserialize_ifaddrs failed\n");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
return 0; // 返回成功
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主函数
|
||||||
|
int getifaddrs(struct ifaddrs **ifap) {
|
||||||
|
// 创建一个套接字
|
||||||
|
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (sockfd < 0) {
|
||||||
|
perror("socket");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 定义服务器地址结构体
|
||||||
|
struct sockaddr_un un;
|
||||||
|
memset(&un, 0, sizeof(un));
|
||||||
|
un.sun_family = AF_UNIX;
|
||||||
|
snprintf(un.sun_path, sizeof(un.sun_path), "%s", "/tmp/.getifaddrs-bridge");
|
||||||
|
// 连接到服务器
|
||||||
|
if (connect(sockfd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
||||||
|
perror("connect");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 发送信号给服务器
|
||||||
|
if (TINY_send_signal(sockfd) < 0) {
|
||||||
|
fprintf(stderr, "send_signal failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 接收数据并反序列化
|
||||||
|
if (TINY_receive_data(sockfd, ifap) < 0) {
|
||||||
|
fprintf(stderr, "receive_data failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 关闭套接字
|
||||||
|
close(sockfd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
222
extra/getifaddrs_bridge/getifaddrs_bridge_server.c
Normal file
222
extra/getifaddrs_bridge/getifaddrs_bridge_server.c
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
// getifaddrs_bridge_server.c -- This file is part of tiny_computer.
|
||||||
|
|
||||||
|
// Copyright (C) 2023 Caten Hu
|
||||||
|
|
||||||
|
// Tiny Computer is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published
|
||||||
|
// by the Free Software Foundation, either version 3 of the License,
|
||||||
|
// or any later version.
|
||||||
|
|
||||||
|
// Tiny Computer is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
// See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
/* this file is mainly generated by Bing */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
|
||||||
|
#define BUFSIZE 1024 // 定义缓冲区大小
|
||||||
|
|
||||||
|
// 定义一个序列化函数,将ifaddrs结构体转换为字节数组
|
||||||
|
int serialize_ifaddrs(struct ifaddrs *ifa, char *buf, int size) {
|
||||||
|
int len = 0; // 记录已经写入的字节数
|
||||||
|
while (ifa != NULL && len < size) {
|
||||||
|
// 写入接口名称
|
||||||
|
int namelen = strlen(ifa->ifa_name) + 1; // 包括结束符
|
||||||
|
if (len + namelen > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, ifa->ifa_name, namelen);
|
||||||
|
len += namelen;
|
||||||
|
// 写入接口标志
|
||||||
|
if (len + sizeof(unsigned int) > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, &ifa->ifa_flags, sizeof(unsigned int));
|
||||||
|
len += sizeof(unsigned int);
|
||||||
|
// 写入接口地址
|
||||||
|
if (ifa->ifa_addr != NULL) {
|
||||||
|
int addrlen = sizeof(struct sockaddr); // 地址结构体长度
|
||||||
|
if (len + addrlen > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, ifa->ifa_addr, addrlen);
|
||||||
|
len += addrlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有地址,写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 写入接口掩码
|
||||||
|
if (ifa->ifa_netmask != NULL) {
|
||||||
|
int masklen = sizeof(struct sockaddr); // 掩码结构体长度
|
||||||
|
if (len + masklen > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, ifa->ifa_netmask, masklen);
|
||||||
|
len += masklen;
|
||||||
|
} else {
|
||||||
|
// 如果没有掩码,写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 写入接口广播地址或点对点地址
|
||||||
|
if (ifa->ifa_flags & IFF_BROADCAST) {
|
||||||
|
// 如果有广播地址
|
||||||
|
if (ifa->ifa_broadaddr != NULL) {
|
||||||
|
int broadlen = sizeof(struct sockaddr); // 广播地址结构体长度
|
||||||
|
if (len + broadlen > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, ifa->ifa_broadaddr, broadlen);
|
||||||
|
len += broadlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有广播地址,写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
} else if (ifa->ifa_flags & IFF_POINTOPOINT) {
|
||||||
|
// 如果有点对点地址
|
||||||
|
if (ifa->ifa_dstaddr != NULL) {
|
||||||
|
int dstlen = sizeof(struct sockaddr); // 点对点地址结构体长度
|
||||||
|
if (len + dstlen > size) break; // 缓冲区不足
|
||||||
|
memcpy(buf + len, ifa->ifa_dstaddr, dstlen);
|
||||||
|
len += dstlen;
|
||||||
|
} else {
|
||||||
|
// 如果没有点对点地址,写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有广播地址或点对点地址,写入两个空字节
|
||||||
|
if (len + 2 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
buf[len + 1] = '\0';
|
||||||
|
len += 2;
|
||||||
|
}
|
||||||
|
// 写入接口数据
|
||||||
|
if (ifa->ifa_data != NULL) {
|
||||||
|
// TODO: 根据不同的地址族,写入不同的数据
|
||||||
|
// 这里暂时省略,只写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
} else {
|
||||||
|
// 如果没有数据,写入一个空字节
|
||||||
|
if (len + 1 > size) break; // 缓冲区不足
|
||||||
|
buf[len] = '\0';
|
||||||
|
len += 1;
|
||||||
|
}
|
||||||
|
// 跳到下一个接口
|
||||||
|
ifa = ifa->ifa_next;
|
||||||
|
}
|
||||||
|
return len; // 返回写入的总字节数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义一个接收信号的函数,从客户端接收一个信号
|
||||||
|
int receive_signal(int sockfd) {
|
||||||
|
char sig; // 定义信号变量
|
||||||
|
int n = read(sockfd, &sig, 1); // 从套接字读取一个字节
|
||||||
|
if (n < 0) {
|
||||||
|
perror("read");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
if (sig == 'S') {
|
||||||
|
// 如果收到信号S,表示客户端需要数据
|
||||||
|
return 0; // 返回成功
|
||||||
|
} else {
|
||||||
|
// 如果收到其他信号,表示无效信号
|
||||||
|
fprintf(stderr, "invalid signal: %c\n", sig);
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义一个发送数据的函数,向客户端发送数据并序列化
|
||||||
|
int send_data(int sockfd) {
|
||||||
|
struct ifaddrs *ifap = NULL; // 定义ifaddrs结构体指针
|
||||||
|
// 调用getifaddrs函数,获取本地接口信息
|
||||||
|
if (getifaddrs(&ifap) < 0) {
|
||||||
|
perror("getifaddrs");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
char buf[BUFSIZE]; // 定义缓冲区
|
||||||
|
// 调用序列化函数,将ifaddrs结构体转换为字节数组
|
||||||
|
int len = serialize_ifaddrs(ifap, buf, BUFSIZE);
|
||||||
|
if (len < 0) {
|
||||||
|
fprintf(stderr, "serialize_ifaddrs failed\n");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
// 向套接字写入数据
|
||||||
|
int n = write(sockfd, buf, len);
|
||||||
|
if (n < 0) {
|
||||||
|
perror("write");
|
||||||
|
return -1; // 返回错误
|
||||||
|
}
|
||||||
|
// 释放ifaddrs结构体
|
||||||
|
freeifaddrs(ifap);
|
||||||
|
return 0; // 返回成功
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主函数
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("usage: %s <socket_path>\n", argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// 创建一个套接字
|
||||||
|
int sockfd = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (sockfd < 0) {
|
||||||
|
perror("socket");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 定义服务器地址结构体
|
||||||
|
struct sockaddr_un un;
|
||||||
|
memset(&un, 0, sizeof(un));
|
||||||
|
un.sun_family = AF_UNIX;
|
||||||
|
snprintf(un.sun_path, sizeof(un.sun_path), "%s", argv[1]);
|
||||||
|
unlink(un.sun_path);
|
||||||
|
// 绑定套接字到服务器地址
|
||||||
|
if (bind(sockfd, (struct sockaddr *)&un, sizeof(un)) < 0) {
|
||||||
|
perror("bind");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 监听套接字
|
||||||
|
if (listen(sockfd, 5) < 0) {
|
||||||
|
perror("listen");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
// 循环接受客户端连接
|
||||||
|
while (1) {
|
||||||
|
int connfd = accept(sockfd, NULL, NULL);
|
||||||
|
if (connfd < 0) {
|
||||||
|
perror("accept");
|
||||||
|
continue; // 如果接受失败,继续循环
|
||||||
|
}
|
||||||
|
// 循环接收和发送数据
|
||||||
|
while (1) {
|
||||||
|
// 接收信号
|
||||||
|
if (receive_signal(connfd) < 0) {
|
||||||
|
fprintf(stderr, "receive_signal failed\n");
|
||||||
|
close(connfd); // 如果接收失败,关闭连接套接字
|
||||||
|
break; // 跳出循环
|
||||||
|
}
|
||||||
|
// 发送数据
|
||||||
|
if (send_data(connfd) < 0) {
|
||||||
|
fprintf(stderr, "send_data failed\n");
|
||||||
|
close(connfd); // 如果发送失败,关闭连接套接字
|
||||||
|
break; // 跳出循环
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 关闭监听套接字
|
||||||
|
close(sockfd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
19
extra/getifaddrs_bridge/readme
Normal file
19
extra/getifaddrs_bridge/readme
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
### 编译
|
||||||
|
|
||||||
|
使用NDK编译getifaddrs_bridge_server.c:
|
||||||
|
|
||||||
|
`aarch64-linux-android-clang getifaddrs_bridge_server.c -o getifaddrs_bridge_server`
|
||||||
|
|
||||||
|
在小小电脑上编译getifaddrs_bridge_client_lib.c:
|
||||||
|
|
||||||
|
`gcc getifaddrs_bridge_client_lib.c -o getifaddrs_bridge_client_lib.so -shared`
|
||||||
|
|
||||||
|
### 使用
|
||||||
|
|
||||||
|
在安卓端:
|
||||||
|
|
||||||
|
`getifaddrs_bridge_server /path/to/container/tmp/.getifaddrs-bridge`
|
||||||
|
|
||||||
|
在proot容器:
|
||||||
|
|
||||||
|
`LD_PRELOAD=/path/to/getifaddrs_bridge_client_lib.so <your_program>`
|
||||||
6
extra/readme
Normal file
6
extra/readme
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
## 这个readme介绍assets文件夹中文件的制作方式。
|
||||||
|
|
||||||
|
### assets.zip
|
||||||
|
|
||||||
|
|
||||||
|
### patch.tar.gz
|
||||||
112
lib/main.dart
112
lib/main.dart
@@ -125,8 +125,10 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
//setState(() {});
|
//setState(() {});
|
||||||
}),
|
}),
|
||||||
SizedBox.fromSize(size: const Size.square(8)),
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
TextFormField(maxLines: null, initialValue: Util.getCurrentProp("boot"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "启动命令"), onChanged: (value) async {
|
ValueListenableBuilder(valueListenable: G.bootTextChange, builder:(context, v, child) {
|
||||||
|
return TextFormField(maxLines: null, initialValue: Util.getCurrentProp("boot"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "启动命令"), onChanged: (value) async {
|
||||||
await Util.setCurrentProp("boot", value);
|
await Util.setCurrentProp("boot", value);
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
SizedBox.fromSize(size: const Size.square(8)),
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
TextFormField(maxLines: null, initialValue: Util.getCurrentProp("vnc"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "vnc启动命令"), onChanged: (value) async {
|
TextFormField(maxLines: null, initialValue: Util.getCurrentProp("vnc"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "vnc启动命令"), onChanged: (value) async {
|
||||||
@@ -136,6 +138,22 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
TextFormField(maxLines: null, initialValue: Util.getCurrentProp("vncUrl"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "网页跳转地址"), onChanged: (value) async {
|
TextFormField(maxLines: null, initialValue: Util.getCurrentProp("vncUrl"), decoration: const InputDecoration(border: OutlineInputBorder(), labelText: "网页跳转地址"), onChanged: (value) async {
|
||||||
await Util.setCurrentProp("vncUrl", value);
|
await Util.setCurrentProp("vncUrl", value);
|
||||||
}),
|
}),
|
||||||
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
|
OutlinedButton(style: D.commandButtonStyle, child: const Text("重置启动命令"), onPressed: () {
|
||||||
|
showDialog(context: context, builder: (context) {
|
||||||
|
return AlertDialog(title: const Text("注意"), content: const Text("是否重置启动命令?"), actions: [
|
||||||
|
TextButton(onPressed:() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}, child: const Text("取消")),
|
||||||
|
TextButton(onPressed:() async {
|
||||||
|
await Util.setCurrentProp("boot", D.boot);
|
||||||
|
G.bootTextChange.value = !G.bootTextChange.value;
|
||||||
|
if (!context.mounted) return;
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}, child: const Text("是")),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}),
|
||||||
],))),
|
],))),
|
||||||
ExpansionPanel(
|
ExpansionPanel(
|
||||||
isExpanded: _expandState[1],
|
isExpanded: _expandState[1],
|
||||||
@@ -176,7 +194,9 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
G.prefs.setBool("isBannerAdsClosed", value);
|
G.prefs.setBool("isBannerAdsClosed", value);
|
||||||
setState(() {});
|
setState(() {
|
||||||
|
G.bannerAdsChange.value = !G.bannerAdsChange.value;
|
||||||
|
});
|
||||||
},),
|
},),
|
||||||
SizedBox.fromSize(size: const Size.square(8)),
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
SwitchListTile(title: const Text("启用终端"), value: Util.getGlobal("isTerminalWriteEnabled") as bool, onChanged:(value) {
|
SwitchListTile(title: const Text("启用终端"), value: Util.getGlobal("isTerminalWriteEnabled") as bool, onChanged:(value) {
|
||||||
@@ -203,7 +223,9 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
G.prefs.setBool("isTerminalCommandsEnabled", value);
|
G.prefs.setBool("isTerminalCommandsEnabled", value);
|
||||||
setState(() {});
|
setState(() {
|
||||||
|
G.terminalPageChange.value = !G.terminalPageChange.value;
|
||||||
|
});
|
||||||
},),
|
},),
|
||||||
SizedBox.fromSize(size: const Size.square(8)),
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
SwitchListTile(title: const Text("终端粘滞键"), value: Util.getGlobal("isStickyKey") as bool, onChanged:(value) {
|
SwitchListTile(title: const Text("终端粘滞键"), value: Util.getGlobal("isStickyKey") as bool, onChanged:(value) {
|
||||||
@@ -215,6 +237,16 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
G.prefs.setBool("autoLaunchVnc", value);
|
G.prefs.setBool("autoLaunchVnc", value);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},),
|
},),
|
||||||
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
|
SwitchListTile(title: const Text("重新安装引导包"), subtitle: const Text("下次启动时生效"), value: Util.getGlobal("reinstallBootstrap") as bool, onChanged:(value) {
|
||||||
|
G.prefs.setBool("reinstallBootstrap", value);
|
||||||
|
setState(() {});
|
||||||
|
},),
|
||||||
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
|
SwitchListTile(title: const Text("getifaddrs桥接"), subtitle: const Text("下次启动时生效"), value: Util.getGlobal("getifaddrsBridge") as bool, onChanged:(value) {
|
||||||
|
G.prefs.setBool("getifaddrsBridge", value);
|
||||||
|
setState(() {});
|
||||||
|
},),
|
||||||
],))),
|
],))),
|
||||||
ExpansionPanel(
|
ExpansionPanel(
|
||||||
isExpanded: _expandState[2],
|
isExpanded: _expandState[2],
|
||||||
@@ -365,7 +397,9 @@ class _SettingPageState extends State<SettingPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class InfoPage extends StatefulWidget {
|
class InfoPage extends StatefulWidget {
|
||||||
const InfoPage({super.key});
|
final bool openFirstInfo;
|
||||||
|
|
||||||
|
const InfoPage({super.key, this.openFirstInfo=false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<InfoPage> createState() => _InfoPageState();
|
State<InfoPage> createState() => _InfoPageState();
|
||||||
@@ -373,6 +407,13 @@ class InfoPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _InfoPageState extends State<InfoPage> {
|
class _InfoPageState extends State<InfoPage> {
|
||||||
final List<bool> _expandState = [false, false, false, false, false];
|
final List<bool> _expandState = [false, false, false, false, false];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_expandState[0] = widget.openFirstInfo;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ExpansionPanelList(
|
return ExpansionPanelList(
|
||||||
@@ -390,7 +431,11 @@ class _InfoPageState extends State<InfoPage> {
|
|||||||
},
|
},
|
||||||
body: const Padding(padding: EdgeInsets.all(8), child: Text("""
|
body: const Padding(padding: EdgeInsets.all(8), child: Text("""
|
||||||
第一次加载大概需要5到10分钟...
|
第一次加载大概需要5到10分钟...
|
||||||
加载完成后,软件会自动跳转到图形界面
|
正常情况下,加载完成后软件会自动跳转到图形界面
|
||||||
|
|
||||||
|
在图形界面时,点击即鼠标左键
|
||||||
|
双指点击为鼠标右键
|
||||||
|
双指划动为鼠标滚轮
|
||||||
|
|
||||||
在图形界面返回,可以回到终端界面和控制界面
|
在图形界面返回,可以回到终端界面和控制界面
|
||||||
你可以在控制界面安装更多软件或者阅读帮助信息
|
你可以在控制界面安装更多软件或者阅读帮助信息
|
||||||
@@ -418,8 +463,8 @@ class _InfoPageState extends State<InfoPage> {
|
|||||||
可能会在使用过程中异常退出(返回错误码9)
|
可能会在使用过程中异常退出(返回错误码9)
|
||||||
届时本软件会提供方案指引你修复
|
届时本软件会提供方案指引你修复
|
||||||
并不难
|
并不难
|
||||||
此软件因为没有权限
|
但是软件没有权限
|
||||||
所以不能帮你修复
|
不能帮你修复
|
||||||
|
|
||||||
如果你给了存储权限
|
如果你给了存储权限
|
||||||
那么通过主目录下的文件夹
|
那么通过主目录下的文件夹
|
||||||
@@ -477,11 +522,11 @@ Vivo Pad,安卓13,看不见鼠标移动(可以去左栏设置开启显示
|
|||||||
也不方便定位原因)
|
也不方便定位原因)
|
||||||
如果你遇到了类似问题
|
如果你遇到了类似问题
|
||||||
不管解没解决
|
不管解没解决
|
||||||
都可以去https://github.com/Cateners/tiny_computer/issues/1留个言
|
都可以去https://github.com/Cateners/tiny_computer/issues/留个言
|
||||||
|
|
||||||
如果软件里有程序正在正常运行
|
如果软件里有程序正在正常运行
|
||||||
请不要强行关闭本软件
|
请不要强行关闭本软件
|
||||||
否则可能会损坏本容器
|
否则可能会损坏容器
|
||||||
特别是在安装某些比较大的软件的时候
|
特别是在安装某些比较大的软件的时候
|
||||||
|
|
||||||
感谢使用!
|
感谢使用!
|
||||||
@@ -902,7 +947,9 @@ SOFTWARE.
|
|||||||
}), body: const Padding(padding: EdgeInsets.all(8), child: Text("""
|
}), body: const Padding(padding: EdgeInsets.all(8), child: Text("""
|
||||||
除由Unity提供的广告功能外, 本软件不会收集你的隐私信息。
|
除由Unity提供的广告功能外, 本软件不会收集你的隐私信息。
|
||||||
|
|
||||||
申请的权限用于以下目的:
|
当然,你在容器系统内部安装或使用的软件行为就不受我控制了,所以我不对其负责。
|
||||||
|
|
||||||
|
本软件申请的权限用于以下目的:
|
||||||
文件相关权限:用于系统访问手机目录;
|
文件相关权限:用于系统访问手机目录;
|
||||||
相机和麦克风:用于推流,默认不会开启。
|
相机和麦克风:用于推流,默认不会开启。
|
||||||
|
|
||||||
@@ -921,17 +968,6 @@ SOFTWARE.
|
|||||||
本程序是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是任何以后版都可以。
|
本程序是自由软件:你可以再分发之和/或依照由自由软件基金会发布的 GNU 通用公共许可证修改之,无论是版本 3 许可证,还是任何以后版都可以。
|
||||||
发布该程序是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
|
发布该程序是希望它能有用,但是并无保障;甚至连可销售和符合某个特定的目的都不保证。请参看 GNU 通用公共许可证,了解详情。
|
||||||
你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看 <https://www.gnu.org/licenses/>。
|
你应该随程序获得一份 GNU 通用公共许可证的复本。如果没有,请看 <https://www.gnu.org/licenses/>。
|
||||||
|
|
||||||
你可能注意到本软件使用了Unity广告服务,
|
|
||||||
那么它是否与本项目有冲突?
|
|
||||||
|
|
||||||
事实上,这个项目不依赖广告,
|
|
||||||
你完全可以自行编译一份不包含广告的版本;
|
|
||||||
|
|
||||||
不管怎么说,我希望这不是一个问题...
|
|
||||||
|
|
||||||
...当然!
|
|
||||||
我还是不想看到你们去编译一个不含广告的版本><
|
|
||||||
"""))),
|
"""))),
|
||||||
ExpansionPanel(
|
ExpansionPanel(
|
||||||
isExpanded: _expandState[4],
|
isExpanded: _expandState[4],
|
||||||
@@ -997,11 +1033,11 @@ class LoadingPage extends StatelessWidget {
|
|||||||
const LoadingPage({super.key});
|
const LoadingPage({super.key});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.fromLTRB(16, 16, 16, 16),
|
padding: EdgeInsets.fromLTRB(16, 16, 16, 16),
|
||||||
child: FractionallySizedBox(
|
child: FractionallySizedBox(
|
||||||
widthFactor: 0.4,
|
widthFactor: 0.4,
|
||||||
@@ -1011,14 +1047,16 @@ class LoadingPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.fromLTRB(0, 0, 0, 8),
|
padding: const EdgeInsets.fromLTRB(0, 0, 0, 8),
|
||||||
child: Text("小小电脑", textScaleFactor: 2),
|
child: ValueListenableBuilder(valueListenable: G.updateText, builder:(context, value, child) {
|
||||||
|
return Text(value, textScaleFactor: 2);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
FakeLoadingStatus(),
|
const FakeLoadingStatus(),
|
||||||
Expanded(child: Padding(padding: EdgeInsets.all(8), child: Card(child: Padding(padding: EdgeInsets.all(8), child:
|
const Expanded(child: Padding(padding: EdgeInsets.all(8), child: Card(child: Padding(padding: EdgeInsets.all(8), child:
|
||||||
Scrollbar(child:
|
Scrollbar(child:
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
child: InfoPage()
|
child: InfoPage(openFirstInfo: true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
@@ -1066,7 +1104,8 @@ class TerminalPage extends StatelessWidget {
|
|||||||
}, child: ValueListenableBuilder(valueListenable: G.termFontScale, builder:(context, value, child) {
|
}, child: ValueListenableBuilder(valueListenable: G.termFontScale, builder:(context, value, child) {
|
||||||
return TerminalView(G.termPtys[G.currentContainer]!.terminal, textScaleFactor: G.termFontScale.value, keyboardType: TextInputType.multiline);
|
return TerminalView(G.termPtys[G.currentContainer]!.terminal, textScaleFactor: G.termFontScale.value, keyboardType: TextInputType.multiline);
|
||||||
},) )),
|
},) )),
|
||||||
(Util.getGlobal("isTerminalCommandsEnabled") as bool)?Padding(padding: const EdgeInsets.all(8), child: Row(children: [AnimatedBuilder(
|
ValueListenableBuilder(valueListenable: G.terminalPageChange, builder:(context, value, child) {
|
||||||
|
return (Util.getGlobal("isTerminalCommandsEnabled") as bool)?Padding(padding: const EdgeInsets.all(8), child: Row(children: [AnimatedBuilder(
|
||||||
animation: G.keyboard,
|
animation: G.keyboard,
|
||||||
builder: (context, child) => ToggleButtons(
|
builder: (context, child) => ToggleButtons(
|
||||||
constraints: const BoxConstraints(minWidth: 32, minHeight: 24),
|
constraints: const BoxConstraints(minWidth: 32, minHeight: 24),
|
||||||
@@ -1096,7 +1135,8 @@ class TerminalPage extends StatelessWidget {
|
|||||||
}, child: Text(D.termCommands[index]["name"]! as String));
|
}, child: Text(D.termCommands[index]["name"]! as String));
|
||||||
}, separatorBuilder:(context, index) {
|
}, separatorBuilder:(context, index) {
|
||||||
return SizedBox.fromSize(size: const Size.square(4));
|
return SizedBox.fromSize(size: const Size.square(4));
|
||||||
}, itemCount: D.termCommands.length))), SizedBox.fromSize(size: const Size(72, 0))])):SizedBox.fromSize(size: const Size.square(0))
|
}, itemCount: D.termCommands.length))), SizedBox.fromSize(size: const Size(72, 0))])):SizedBox.fromSize(size: const Size.square(0));
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1177,7 +1217,7 @@ class _FastCommandsState extends State<FastCommands> {
|
|||||||
},);
|
},);
|
||||||
}, onLongPress: () {
|
}, onLongPress: () {
|
||||||
showDialog(context: context, builder: (context) {
|
showDialog(context: context, builder: (context) {
|
||||||
return AlertDialog(content: const Text("是否重置所有快捷指令?"), actions: [
|
return AlertDialog(title: const Text("重置指令"), content: const Text("是否重置所有快捷指令?"), actions: [
|
||||||
TextButton(onPressed:() {
|
TextButton(onPressed:() {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}, child: const Text("取消")),
|
}, child: const Text("取消")),
|
||||||
@@ -1230,7 +1270,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title),
|
title: Text(isLoadingComplete?Util.getCurrentProp("name"):widget.title),
|
||||||
),
|
),
|
||||||
body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [
|
body: isLoadingComplete?Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
(Util.getGlobal("isBannerAdsClosed") as bool)||bannerAdsFailedToLoad?SizedBox.fromSize(size: const Size.square(0)):UnityBannerAd(
|
ValueListenableBuilder(valueListenable: G.bannerAdsChange, builder:(context, value, child) {
|
||||||
|
return (Util.getGlobal("isBannerAdsClosed") as bool)||bannerAdsFailedToLoad?SizedBox.fromSize(size: const Size.square(0)):UnityBannerAd(
|
||||||
placementId: AdManager.bannerAdPlacementId,
|
placementId: AdManager.bannerAdPlacementId,
|
||||||
onLoad: (placementId) => debugPrint('Banner loaded: $placementId'),
|
onLoad: (placementId) => debugPrint('Banner loaded: $placementId'),
|
||||||
onClick: (placementId) => debugPrint('Banner clicked: $placementId'),
|
onClick: (placementId) => debugPrint('Banner clicked: $placementId'),
|
||||||
@@ -1240,7 +1281,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
bannerAdsFailedToLoad = true;
|
bannerAdsFailedToLoad = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
), Expanded(child: ValueListenableBuilder(valueListenable: G.pageIndex, builder: (context, value, child) {
|
);
|
||||||
|
}), Expanded(child: ValueListenableBuilder(valueListenable: G.pageIndex, builder: (context, value, child) {
|
||||||
return IndexedStack(index: G.pageIndex.value, children: [const TerminalPage(), Padding(
|
return IndexedStack(index: G.pageIndex.value, children: [const TerminalPage(), Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Scrollbar(child: SingleChildScrollView(restorationId: "control-scroll", child: Column(
|
child: Scrollbar(child: SingleChildScrollView(restorationId: "control-scroll", child: Column(
|
||||||
@@ -1263,7 +1305,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Column(children: [
|
Column(children: [
|
||||||
const SettingPage(),
|
const SettingPage(),
|
||||||
SizedBox.fromSize(size: const Size.square(8)),
|
SizedBox.fromSize(size: const Size.square(8)),
|
||||||
const InfoPage()
|
const InfoPage(openFirstInfo: false)
|
||||||
])
|
])
|
||||||
)))
|
)))
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class Util {
|
|||||||
//int vip = 0 用户等级,vip免广告,你要改吗?(ToT)
|
//int vip = 0 用户等级,vip免广告,你要改吗?(ToT)
|
||||||
//bool isStickyKey = true 终端ctrl, shift, alt键是否粘滞
|
//bool isStickyKey = true 终端ctrl, shift, alt键是否粘滞
|
||||||
//String defaultFFmpegCommand 默认推流命令
|
//String defaultFFmpegCommand 默认推流命令
|
||||||
|
//bool reinstallBootstrap = false 下次启动是否重装引导包
|
||||||
//? int bootstrapVersion: 启动包版本
|
//? int bootstrapVersion: 启动包版本
|
||||||
//String[] containersInfo: 所有容器信息(json)
|
//String[] containersInfo: 所有容器信息(json)
|
||||||
//{name, boot:"\$DATA_DIR/bin/proot ...", vnc:"startnovnc", vncUrl:"...", commands:[{name:"更新和升级", command:"apt update -y && apt upgrade -y"},
|
//{name, boot:"\$DATA_DIR/bin/proot ...", vnc:"startnovnc", vncUrl:"...", commands:[{name:"更新和升级", command:"apt update -y && apt upgrade -y"},
|
||||||
@@ -108,6 +109,8 @@ class Util {
|
|||||||
case "termFontScale" : return b ? G.prefs.getDouble(key)! : (value){G.prefs.setDouble(key, value); return value;}(1.0);
|
case "termFontScale" : return b ? G.prefs.getDouble(key)! : (value){G.prefs.setDouble(key, value); return value;}(1.0);
|
||||||
case "vip" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
case "vip" : return b ? G.prefs.getInt(key)! : (value){G.prefs.setInt(key, value); return value;}(0);
|
||||||
case "isStickyKey" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
|
case "isStickyKey" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(true);
|
||||||
|
case "reinstallBootstrap" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||||
|
case "getifaddrsBridge" : return b ? G.prefs.getBool(key)! : (value){G.prefs.setBool(key, value); return value;}(false);
|
||||||
case "defaultFFmpegCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("-hide_banner -an -max_delay 1000000 -r 30 -f android_camera -camera_index 0 -i 0:0 -vf scale=iw/2:-1 -rtsp_transport udp -f rtsp rtsp://127.0.0.1:8554/stream");
|
case "defaultFFmpegCommand" : return b ? G.prefs.getString(key)! : (value){G.prefs.setString(key, value); return value;}("-hide_banner -an -max_delay 1000000 -r 30 -f android_camera -camera_index 0 -i 0:0 -vf scale=iw/2:-1 -rtsp_transport udp -f rtsp rtsp://127.0.0.1:8554/stream");
|
||||||
case "containersInfo" : return G.prefs.getStringList(key)!;
|
case "containersInfo" : return G.prefs.getStringList(key)!;
|
||||||
case "adsBonus" : return b ? G.prefs.getStringList(key)! : (value){G.prefs.setStringList(key, value); return value;}([].cast<String>());
|
case "adsBonus" : return b ? G.prefs.getStringList(key)! : (value){G.prefs.setStringList(key, value); return value;}([].cast<String>());
|
||||||
@@ -377,6 +380,7 @@ class D {
|
|||||||
{"name": "F10", "key": TerminalKey.f10},
|
{"name": "F10", "key": TerminalKey.f10},
|
||||||
{"name": "F11", "key": TerminalKey.f11},
|
{"name": "F11", "key": TerminalKey.f11},
|
||||||
{"name": "F12", "key": TerminalKey.f12},
|
{"name": "F12", "key": TerminalKey.f12},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
//看广告可以获得的奖励。
|
//看广告可以获得的奖励。
|
||||||
@@ -405,6 +409,8 @@ class D {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const String boot = "\$DATA_DIR/bin/proot -H --change-id=1000:1000 --pwd=/home/tiny --rootfs=\$CONTAINER_DIR --mount=/system --mount=/apex --kill-on-exit --mount=/storage:/storage --sysvipc -L --link2symlink --mount=/proc:/proc --mount=/dev:/dev --mount=\$CONTAINER_DIR/tmp:/dev/shm --mount=/dev/urandom:/dev/random --mount=/proc/self/fd:/dev/fd --mount=/proc/self/fd/0:/dev/stdin --mount=/proc/self/fd/1:/dev/stdout --mount=/proc/self/fd/2:/dev/stderr --mount=/dev/null:/dev/tty0 --mount=/dev/null:/proc/sys/kernel/cap_last_cap --mount=/storage/self/primary:/media/sd --mount=\$DATA_DIR/share:/home/tiny/公共 --mount=\$DATA_DIR/tiny:/home/tiny/.local/share/tiny --mount=/storage/self/primary/Fonts:/usr/share/fonts/wpsm --mount=/storage/self/primary/AppFiles/Fonts:/usr/share/fonts/yozom --mount=/system/fonts:/usr/share/fonts/androidm --mount=/storage/self/primary/Pictures:/home/tiny/图片 --mount=/storage/self/primary/Music:/home/tiny/音乐 --mount=/storage/self/primary/Movies:/home/tiny/视频 --mount=/storage/self/primary/Download:/home/tiny/下载 --mount=/storage/self/primary/DCIM:/home/tiny/照片 --mount=/storage/self/primary/Documents:/home/tiny/文档 --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.stat:/proc/stat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.version:/proc/version --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/bus:/proc/bus --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/buddyinfo:/proc/buddyinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/cgroups:/proc/cgroups --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/consoles:/proc/consoles --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/crypto:/proc/crypto --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/devices:/proc/devices --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/diskstats:/proc/diskstats --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/execdomains:/proc/execdomains --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/fb:/proc/fb --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/filesystems:/proc/filesystems --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/interrupts:/proc/interrupts --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/iomem:/proc/iomem --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/ioports:/proc/ioports --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kallsyms:/proc/kallsyms --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/keys:/proc/keys --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/key-users:/proc/key-users --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kpageflags:/proc/kpageflags --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/loadavg:/proc/loadavg --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/locks:/proc/locks --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/misc:/proc/misc --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/modules:/proc/modules --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/pagetypeinfo:/proc/pagetypeinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/partitions:/proc/partitions --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/sched_debug:/proc/sched_debug --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/softirqs:/proc/softirqs --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/timer_list:/proc/timer_list --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/uptime:/proc/uptime --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmallocinfo:/proc/vmallocinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmstat:/proc/vmstat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/zoneinfo:/proc/zoneinfo /usr/bin/env -i HOSTNAME=TINY HOME=/home/tiny USER=tiny TERM=xterm-256color SDL_IM_MODULE=fcitx XMODIFIERS=@im=fcitx QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx TMOE_CHROOT=false TMOE_PROOT=true TMPDIR=/tmp MOZ_FAKE_NO_SANDBOX=1 DISPLAY=:4 PULSE_SERVER=tcp:127.0.0.1:4718 LANG=zh_CN.UTF-8 SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games \$EXTRA_OPT /bin/bash -l";
|
||||||
|
|
||||||
static final ButtonStyle commandButtonStyle = OutlinedButton.styleFrom(
|
static final ButtonStyle commandButtonStyle = OutlinedButton.styleFrom(
|
||||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
minimumSize: const Size(0, 0),
|
minimumSize: const Size(0, 0),
|
||||||
@@ -441,6 +447,10 @@ class G {
|
|||||||
static String streamingOutput = "";
|
static String streamingOutput = "";
|
||||||
static late Pty streamServerPty;
|
static late Pty streamServerPty;
|
||||||
static ValueNotifier<int> pageIndex = ValueNotifier(0); //主界面索引
|
static ValueNotifier<int> pageIndex = ValueNotifier(0); //主界面索引
|
||||||
|
static ValueNotifier<bool> terminalPageChange = ValueNotifier(true); //更改值,用于刷新小键盘
|
||||||
|
static ValueNotifier<bool> bannerAdsChange = ValueNotifier(true); //更改值,用于刷新banner广告
|
||||||
|
static ValueNotifier<bool> bootTextChange = ValueNotifier(true); //更改值,用于刷新启动命令
|
||||||
|
static ValueNotifier<String> updateText = ValueNotifier("小小电脑"); //加载界面的说明文字
|
||||||
|
|
||||||
|
|
||||||
static late SharedPreferences prefs;
|
static late SharedPreferences prefs;
|
||||||
@@ -532,6 +542,8 @@ class Workflow {
|
|||||||
Util.createDirFromString("${G.dataPath}/tmp");
|
Util.createDirFromString("${G.dataPath}/tmp");
|
||||||
//给proot的tmp文件夹,虽然我不知道为什么proot要这个
|
//给proot的tmp文件夹,虽然我不知道为什么proot要这个
|
||||||
Util.createDirFromString("${G.dataPath}/proot_tmp");
|
Util.createDirFromString("${G.dataPath}/proot_tmp");
|
||||||
|
//给pulseaudio的tmp文件夹
|
||||||
|
Util.createDirFromString("${G.dataPath}/pulseaudio_tmp");
|
||||||
//解压后得到bin文件夹和libexec文件夹
|
//解压后得到bin文件夹和libexec文件夹
|
||||||
//bin存放了proot, pulseaudio, tar等
|
//bin存放了proot, pulseaudio, tar等
|
||||||
//libexec存放了proot loader
|
//libexec存放了proot loader
|
||||||
@@ -539,6 +551,12 @@ class Workflow {
|
|||||||
"assets/assets.zip",
|
"assets/assets.zip",
|
||||||
"${G.dataPath}/assets.zip",
|
"${G.dataPath}/assets.zip",
|
||||||
);
|
);
|
||||||
|
//patch.tar.gz存放了tiny文件夹
|
||||||
|
//里面是一些补丁,会被挂载到~/.local/share/tiny
|
||||||
|
await Util.copyAsset(
|
||||||
|
"assets/patch.tar.gz",
|
||||||
|
"${G.dataPath}/patch.tar.gz",
|
||||||
|
);
|
||||||
//dddd
|
//dddd
|
||||||
await Util.copyAsset(
|
await Util.copyAsset(
|
||||||
"assets/busybox",
|
"assets/busybox",
|
||||||
@@ -549,19 +567,24 @@ class Workflow {
|
|||||||
export DATA_DIR=${G.dataPath}
|
export DATA_DIR=${G.dataPath}
|
||||||
cd \$DATA_DIR
|
cd \$DATA_DIR
|
||||||
chmod +x busybox
|
chmod +x busybox
|
||||||
\$DATA_DIR/busybox unzip assets.zip
|
\$DATA_DIR/busybox unzip -o assets.zip
|
||||||
chmod -R +x bin/*
|
chmod -R +x bin/*
|
||||||
chmod -R +x libexec/proot/*
|
chmod -R +x libexec/proot/*
|
||||||
chmod 1777 tmp
|
chmod 1777 tmp
|
||||||
ln -s \$DATA_DIR/busybox \$DATA_DIR/bin/xz
|
ln -sf \$DATA_DIR/busybox \$DATA_DIR/bin/xz
|
||||||
\$DATA_DIR/busybox rm -rf assets.zip
|
ln -sf \$DATA_DIR/busybox \$DATA_DIR/bin/gzip
|
||||||
|
\$DATA_DIR/bin/tar zxf patch.tar.gz
|
||||||
|
\$DATA_DIR/busybox rm -rf assets.zip patch.tar.gz
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
//初次启动要做的事情
|
//初次启动要做的事情
|
||||||
static Future<void> initForFirstTime() async {
|
static Future<void> initForFirstTime() async {
|
||||||
//首先设置bootstrap
|
//首先设置bootstrap
|
||||||
|
G.updateText.value = "正在安装引导包";
|
||||||
await setupBootstrap();
|
await setupBootstrap();
|
||||||
|
|
||||||
|
G.updateText.value = "正在复制容器系统";
|
||||||
//存放容器的文件夹0和存放硬链接的文件夹.l2s
|
//存放容器的文件夹0和存放硬链接的文件夹.l2s
|
||||||
Util.createDirFromString("${G.dataPath}/containers/0/.l2s");
|
Util.createDirFromString("${G.dataPath}/containers/0/.l2s");
|
||||||
//这个是容器rootfs,被split命令分成了xa*
|
//这个是容器rootfs,被split命令分成了xa*
|
||||||
@@ -572,6 +595,7 @@ ln -s \$DATA_DIR/busybox \$DATA_DIR/bin/xz
|
|||||||
await Util.copyAsset("assets/$name", "${G.dataPath}/$name");
|
await Util.copyAsset("assets/$name", "${G.dataPath}/$name");
|
||||||
}
|
}
|
||||||
//-J
|
//-J
|
||||||
|
G.updateText.value = "正在安装容器系统";
|
||||||
await Util.execute(
|
await Util.execute(
|
||||||
"""
|
"""
|
||||||
export DATA_DIR=${G.dataPath}
|
export DATA_DIR=${G.dataPath}
|
||||||
@@ -604,11 +628,12 @@ done
|
|||||||
//$DATA_DIR是数据文件夹, $CONTAINER_DIR是容器根目录
|
//$DATA_DIR是数据文件夹, $CONTAINER_DIR是容器根目录
|
||||||
await G.prefs.setStringList("containersInfo", ["""{
|
await G.prefs.setStringList("containersInfo", ["""{
|
||||||
"name":"Debian Bookworm",
|
"name":"Debian Bookworm",
|
||||||
"boot":"\$DATA_DIR/bin/proot -H --change-id=1000:1000 --pwd=/home/tiny --rootfs=\$CONTAINER_DIR --mount=/system --mount=/apex --kill-on-exit --mount=/storage:/storage --sysvipc -L --link2symlink --mount=/proc:/proc --mount=/dev:/dev --mount=\$CONTAINER_DIR/tmp:/dev/shm --mount=/dev/urandom:/dev/random --mount=/proc/self/fd:/dev/fd --mount=/proc/self/fd/0:/dev/stdin --mount=/proc/self/fd/1:/dev/stdout --mount=/proc/self/fd/2:/dev/stderr --mount=/dev/null:/dev/tty0 --mount=/dev/null:/proc/sys/kernel/cap_last_cap --mount=/storage/self/primary:/media/sd --mount=\$DATA_DIR/share:/home/tiny/公共 --mount=/storage/self/primary/Fonts:/usr/share/fonts/wpsm --mount=/storage/self/primary/AppFiles/Fonts:/usr/share/fonts/yozom --mount=/system/fonts:/usr/share/fonts/androidm --mount=/storage/self/primary/Pictures:/home/tiny/图片 --mount=/storage/self/primary/Music:/home/tiny/音乐 --mount=/storage/self/primary/Movies:/home/tiny/视频 --mount=/storage/self/primary/Download:/home/tiny/下载 --mount=/storage/self/primary/DCIM:/home/tiny/照片 --mount=/storage/self/primary/Documents:/home/tiny/文档 --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.stat:/proc/stat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/.tmoe-container.version:/proc/version --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/bus:/proc/bus --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/buddyinfo:/proc/buddyinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/cgroups:/proc/cgroups --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/consoles:/proc/consoles --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/crypto:/proc/crypto --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/devices:/proc/devices --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/diskstats:/proc/diskstats --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/execdomains:/proc/execdomains --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/fb:/proc/fb --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/filesystems:/proc/filesystems --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/interrupts:/proc/interrupts --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/iomem:/proc/iomem --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/ioports:/proc/ioports --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kallsyms:/proc/kallsyms --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/keys:/proc/keys --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/key-users:/proc/key-users --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/kpageflags:/proc/kpageflags --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/loadavg:/proc/loadavg --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/locks:/proc/locks --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/misc:/proc/misc --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/modules:/proc/modules --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/pagetypeinfo:/proc/pagetypeinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/partitions:/proc/partitions --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/sched_debug:/proc/sched_debug --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/softirqs:/proc/softirqs --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/timer_list:/proc/timer_list --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/uptime:/proc/uptime --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmallocinfo:/proc/vmallocinfo --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/vmstat:/proc/vmstat --mount=\$CONTAINER_DIR/usr/local/etc/tmoe-linux/proot_proc/zoneinfo:/proc/zoneinfo /usr/bin/env -i HOSTNAME=TINY HOME=/home/tiny USER=tiny TERM=xterm-256color SDL_IM_MODULE=fcitx XMODIFIERS=@im=fcitx QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx TMOE_CHROOT=false TMOE_PROOT=true TMPDIR=/tmp MOZ_FAKE_NO_SANDBOX=1 DISPLAY=:4 PULSE_SERVER=tcp:127.0.0.1:4718 LANG=zh_CN.UTF-8 SHELL=/bin/bash PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games \$EXTRA_OPT /bin/bash -l",
|
"boot":"${D.boot}",
|
||||||
"vnc":"startnovnc &",
|
"vnc":"startnovnc &",
|
||||||
"vncUrl":"http://localhost:36082/vnc.html?host=localhost&port=36082&autoconnect=true&resize=remote&password=12345678",
|
"vncUrl":"http://localhost:36082/vnc.html?host=localhost&port=36082&autoconnect=true&resize=remote&password=12345678",
|
||||||
"commands":${jsonEncode(D.commands)}
|
"commands":${jsonEncode(D.commands)}
|
||||||
}"""]);
|
}"""]);
|
||||||
|
G.updateText.value = "安装完成";
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> initData() async {
|
static Future<void> initData() async {
|
||||||
@@ -634,6 +659,13 @@ done
|
|||||||
}
|
}
|
||||||
G.currentContainer = Util.getGlobal("defaultContainer") as int;
|
G.currentContainer = Util.getGlobal("defaultContainer") as int;
|
||||||
|
|
||||||
|
//是否需要重新安装引导包?
|
||||||
|
if (Util.getGlobal("reinstallBootstrap")) {
|
||||||
|
G.updateText.value = "正在重新安装引导包";
|
||||||
|
await setupBootstrap();
|
||||||
|
G.prefs.setBool("reinstallBootstrap", false);
|
||||||
|
}
|
||||||
|
|
||||||
G.termFontScale.value = Util.getGlobal("termFontScale") as double;
|
G.termFontScale.value = Util.getGlobal("termFontScale") as double;
|
||||||
|
|
||||||
G.controller = WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);
|
G.controller = WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||||
@@ -684,23 +716,24 @@ done
|
|||||||
//pulseaudio还需要一个文件夹放配置,这里用share
|
//pulseaudio还需要一个文件夹放配置,这里用share
|
||||||
G.audioPty!.write(const Utf8Encoder().convert("""
|
G.audioPty!.write(const Utf8Encoder().convert("""
|
||||||
export DATA_DIR=${G.dataPath}
|
export DATA_DIR=${G.dataPath}
|
||||||
cd \$DATA_DIR/..
|
|
||||||
export TMPDIR=\$PWD/cache
|
|
||||||
cd \$DATA_DIR
|
|
||||||
export HOME=\$DATA_DIR/share
|
|
||||||
export LD_LIBRARY_PATH=\$DATA_DIR/bin
|
|
||||||
\$DATA_DIR/busybox sed "s/4713/${Util.getGlobal("defaultAudioPort") as int}/g" \$DATA_DIR/bin/pulseaudio.conf > \$DATA_DIR/bin/pulseaudio.conf.tmp
|
\$DATA_DIR/busybox sed "s/4713/${Util.getGlobal("defaultAudioPort") as int}/g" \$DATA_DIR/bin/pulseaudio.conf > \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||||
\$DATA_DIR/bin/pulseaudio -F \$DATA_DIR/bin/pulseaudio.conf.tmp
|
TMPDIR=\$DATA_DIR/pulseaudio_tmp HOME=\$DATA_DIR/pulseaudio_tmp XDG_CONFIG_HOME=\$DATA_DIR/pulseaudio_tmp LD_LIBRARY_PATH=\$DATA_DIR/bin \$DATA_DIR/bin/pulseaudio -F \$DATA_DIR/bin/pulseaudio.conf.tmp
|
||||||
exit
|
exit
|
||||||
"""));
|
"""));
|
||||||
await G.audioPty?.exitCode;
|
await G.audioPty?.exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> launchCurrentContainer() async {
|
static Future<void> launchCurrentContainer() async {
|
||||||
|
String extraOpt = "";
|
||||||
|
if (Util.getGlobal("getifaddrsBridge")) {
|
||||||
|
Util.execute("${G.dataPath}/bin/getifaddrs_bridge_server ${G.dataPath}/containers/${G.currentContainer}/tmp/.getifaddrs-bridge");
|
||||||
|
extraOpt += "LD_PRELOAD=/home/tiny/.local/share/tiny/extra/getifaddrs_bridge_client_lib.so ";
|
||||||
|
}
|
||||||
Util.termWrite(
|
Util.termWrite(
|
||||||
"""
|
"""
|
||||||
export DATA_DIR=${G.dataPath}
|
export DATA_DIR=${G.dataPath}
|
||||||
export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer}
|
export CONTAINER_DIR=\$DATA_DIR/containers/${G.currentContainer}
|
||||||
|
export EXTRA_OPT="$extraOpt"
|
||||||
#export PROOT_L2S_DIR=\$DATA_DIR/containers/0/.l2s
|
#export PROOT_L2S_DIR=\$DATA_DIR/containers/0/.l2s
|
||||||
cd \$DATA_DIR
|
cd \$DATA_DIR
|
||||||
export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
|
export PROOT_TMP_DIR=\$DATA_DIR/proot_tmp
|
||||||
|
|||||||
85
pubspec.lock
85
pubspec.lock
@@ -101,10 +101,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: file
|
name: file
|
||||||
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
|
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.4"
|
version: "7.0.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -212,10 +212,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1"
|
sha256: e595b98692943b4881b219f0a9e3945118d3c16bd7e2813f98ec6e532d905f72
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.1"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -276,10 +276,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: permission_handler_platform_interface
|
name: permission_handler_platform_interface
|
||||||
sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2
|
sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.11.5"
|
version: "3.12.0"
|
||||||
permission_handler_windows:
|
permission_handler_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -292,10 +292,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: platform
|
name: platform
|
||||||
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
|
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.3"
|
||||||
platform_info:
|
platform_info:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -328,23 +328,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.2"
|
version: "3.1.2"
|
||||||
saf:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
path: "."
|
|
||||||
ref: HEAD
|
|
||||||
resolved-ref: e3aa3fcbd031f2645688e97ebd5a4f14a014bd42
|
|
||||||
url: "https://github.com/Cateners/saf"
|
|
||||||
source: git
|
|
||||||
version: "1.0.3+3"
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: shared_preferences
|
name: shared_preferences
|
||||||
sha256: b7f41bad7e521d205998772545de63ff4e6c97714775902c199353f8bf1511ac
|
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.1"
|
version: "2.2.2"
|
||||||
shared_preferences_android:
|
shared_preferences_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -365,10 +356,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_linux
|
name: shared_preferences_linux
|
||||||
sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a
|
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.3.2"
|
||||||
shared_preferences_platform_interface:
|
shared_preferences_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -389,10 +380,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: shared_preferences_windows
|
name: shared_preferences_windows
|
||||||
sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f
|
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.1"
|
version: "2.3.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -458,74 +449,74 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: unity_ads_plugin
|
name: unity_ads_plugin
|
||||||
sha256: "2b19ff02089e5a0d1a6549a2cd9d2baf5f8733bdda296d947d411a293f0bffda"
|
sha256: "75b0b87697a9601971eacd2cd37458b88cf88f062af6f21c67c9fb28a11699d9"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.8"
|
version: "0.3.10"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: url_launcher
|
name: url_launcher
|
||||||
sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27"
|
sha256: b1c9e98774adf8820c96fbc7ae3601231d324a7d5ebd8babe27b6dfac91357ba
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.14"
|
version: "6.2.1"
|
||||||
url_launcher_android:
|
url_launcher_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_android
|
name: url_launcher_android
|
||||||
sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330
|
sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0"
|
version: "6.2.0"
|
||||||
url_launcher_ios:
|
url_launcher_ios:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_ios
|
name: url_launcher_ios
|
||||||
sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f"
|
sha256: "4ac97281cf60e2e8c5cc703b2b28528f9b50c8f7cebc71df6bdf0845f647268a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.5"
|
version: "6.2.0"
|
||||||
url_launcher_linux:
|
url_launcher_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_linux
|
name: url_launcher_linux
|
||||||
sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e
|
sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.6"
|
version: "3.1.0"
|
||||||
url_launcher_macos:
|
url_launcher_macos:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_macos
|
name: url_launcher_macos
|
||||||
sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88
|
sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.7"
|
version: "3.1.0"
|
||||||
url_launcher_platform_interface:
|
url_launcher_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_platform_interface
|
name: url_launcher_platform_interface
|
||||||
sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618"
|
sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.5"
|
version: "2.2.0"
|
||||||
url_launcher_web:
|
url_launcher_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_web
|
name: url_launcher_web
|
||||||
sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5"
|
sha256: "7fd2f55fe86cea2897b963e864dc01a7eb0719ecc65fcef4c1cc3d686d718bb2"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.20"
|
version: "2.2.0"
|
||||||
url_launcher_windows:
|
url_launcher_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: url_launcher_windows
|
name: url_launcher_windows
|
||||||
sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069"
|
sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.8"
|
version: "3.1.0"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -546,18 +537,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: webview_flutter
|
name: webview_flutter
|
||||||
sha256: c1ab9b81090705c6069197d9fdc1625e587b52b8d70cdde2339d177ad0dbb98e
|
sha256: "42393b4492e629aa3a88618530a4a00de8bb46e50e7b3993fedbfdc5352f0dbf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.4.1"
|
version: "4.4.2"
|
||||||
webview_flutter_android:
|
webview_flutter_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: webview_flutter_android
|
name: webview_flutter_android
|
||||||
sha256: b0cd33dd7d3dd8e5f664e11a19e17ba12c352647269921a3b568406b001f1dff
|
sha256: "8326ee235f87605a2bfc444a4abc897f4abc78d83f054ba7d3d1074ce82b4fbf"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.12.0"
|
version: "3.12.1"
|
||||||
webview_flutter_platform_interface:
|
webview_flutter_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -570,10 +561,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: webview_flutter_wkwebview
|
name: webview_flutter_wkwebview
|
||||||
sha256: "30b9af6bdd457b44c08748b9190d23208b5165357cc2eb57914fee1366c42974"
|
sha256: accdaaa49a2aca2dc3c3230907988954cdd23fed0a19525d6c9789d380f4dc76
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.9.1"
|
version: "3.9.4"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -43,8 +43,6 @@ dependencies:
|
|||||||
unity_ads_plugin: ^0.3.8
|
unity_ads_plugin: ^0.3.8
|
||||||
clipboard: ^0.1.3
|
clipboard: ^0.1.3
|
||||||
ffmpeg_kit_flutter_full_gpl: ^6.0.3
|
ffmpeg_kit_flutter_full_gpl: ^6.0.3
|
||||||
saf:
|
|
||||||
git: https://github.com/Cateners/saf
|
|
||||||
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
|
|||||||
Reference in New Issue
Block a user