Package ntlf9t: cleanup Makefiles
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
parent
a7b1bdaf67
commit
08ca6f7816
@ -10,35 +10,28 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ShadowVPN
|
||||
PKG_VERSION:=0.2.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELESE)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/aa65535/openwrt-shadowvpn/releases/download/v$(PKG_VERSION)
|
||||
PKG_HASH:=53b445cf47262f407bfef72d32bc6ca5d1341dcd3878ac2b4cd35ee030199dea
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_MAINTAINER:=clowwindy <clowwindy42@gmail.com>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ShadowVPN
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=A fast, safe VPN based on libsodium
|
||||
URL:=https://github.com/clowwindy/ShadowVPN
|
||||
DEPENDS:=+kmod-tun +ip
|
||||
endef
|
||||
|
||||
define Package/ShadowVPN/description
|
||||
A fast, safe VPN based on libsodium
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=A fast, safe VPN based on libsodium
|
||||
URL:=https://github.com/clowwindy/ShadowVPN
|
||||
DEPENDS:=+kmod-tun +ip
|
||||
endef
|
||||
|
||||
define Package/ShadowVPN/conffiles
|
||||
@ -46,17 +39,17 @@ define Package/ShadowVPN/conffiles
|
||||
endef
|
||||
|
||||
define Package/ShadowVPN/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/shadowvpn.init $(1)/etc/init.d/shadowvpn
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/shadowvpn.config $(1)/etc/config/shadowvpn
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/shadowvpn.init $(1)/etc/init.d/shadowvpn
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DATA) ./files/shadowvpn.hotplug $(1)/etc/hotplug.d/iface/30-shadowvpn
|
||||
$(INSTALL_DIR) $(1)/etc/shadowvpn
|
||||
$(INSTALL_DATA) ./files/client_up.sh $(1)/etc/shadowvpn/client_up.sh
|
||||
$(INSTALL_DATA) ./files/client_down.sh $(1)/etc/shadowvpn/client_down.sh
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/shadowvpn $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DATA) ./files/shadowvpn.hotplug $(1)/etc/hotplug.d/iface/30-shadowvpn
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/shadowvpn $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ShadowVPN))
|
||||
51
package/ntlf9t/chinadns/Makefile
Normal file
51
package/ntlf9t/chinadns/Makefile
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright (C) 2014-2018 OpenWrt-dist
|
||||
# Copyright (C) 2014-2018 Jian Chang <aa65535@live.com>
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=chinadns
|
||||
PKG_VERSION:=1.3.3
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/aa65535/ChinaDNS/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=74e53af32f8aa2ca7e63697385f12d89a06c486641556cfd8bc3f085d87e55ad
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/ChinaDNS-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Jian Chang <aa65535@live.com>
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/chinadns
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Protect yourself against DNS poisoning in China.
|
||||
URL:=https://github.com/shadowsocks/ChinaDNS
|
||||
endef
|
||||
|
||||
define Package/chinadns/conffiles
|
||||
/usr/share/chinadns/chnroute.txt
|
||||
/usr/share/chinadns/iplist.txt
|
||||
endef
|
||||
|
||||
define Package/chinadns/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/chinadns $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/usr/share/chinadns
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/share/chnroute.txt $(1)/usr/share/chinadns/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/share/iplist.txt $(1)/usr/share/chinadns/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,chinadns))
|
||||
@ -1 +0,0 @@
|
||||
12
|
||||
@ -1 +0,0 @@
|
||||
12
|
||||
@ -1,154 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
**********************************************************************
|
||||
*
|
||||
* Dynamic list implementation
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#define EMPTYLIST NULL
|
||||
|
||||
void init_list(struct list *l,int keysize) {
|
||||
l->first=l->last=NULL;
|
||||
l->keysize=keysize;
|
||||
l->count=0;
|
||||
}
|
||||
|
||||
struct list_node *add_elem(struct list *l,void *elem) {
|
||||
struct list_node *newnode=(struct list_node*)malloc(sizeof(struct list_node));
|
||||
newnode->data=elem;
|
||||
newnode->previous=l->last;
|
||||
newnode->next=NULL;
|
||||
if (l->count==0) {
|
||||
l->first=l->last=newnode;
|
||||
}
|
||||
else {
|
||||
l->last->next=newnode;
|
||||
l->last=newnode;
|
||||
}
|
||||
l->count++;
|
||||
return newnode;
|
||||
}
|
||||
|
||||
void delete_node(struct list *l,struct list_node *node) {
|
||||
if (l->count==1) {
|
||||
l->first=l->last=NULL;
|
||||
}
|
||||
else if (node==l->first) {
|
||||
node->next->previous=NULL;
|
||||
l->first=node->next;
|
||||
}
|
||||
else if (node==l->last) {
|
||||
node->previous->next=NULL;
|
||||
l->last=node->previous;
|
||||
}
|
||||
else {
|
||||
node->previous->next=node->next;
|
||||
node->next->previous=node->previous;
|
||||
}
|
||||
l->count--;
|
||||
free(node);
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
void destroy_node(struct list *l,struct list_node *node) {
|
||||
free(node->data);
|
||||
node->data=NULL;
|
||||
delete_node(l,node);
|
||||
}
|
||||
|
||||
int is_EMPTYLIST_list(struct list *l) {
|
||||
return (l->count==0?TRUE:FALSE);
|
||||
}
|
||||
|
||||
int get_list_count(struct list *l) {
|
||||
return l->count;
|
||||
}
|
||||
|
||||
void *first_elem(struct list *l) {
|
||||
return l->first->data;
|
||||
}
|
||||
|
||||
struct list_node *first_node(struct list *l) {
|
||||
return l->first;
|
||||
}
|
||||
|
||||
void *last_elem(struct list *l) {
|
||||
return l->last->data;
|
||||
}
|
||||
|
||||
struct list_node *last_node(struct list *l) {
|
||||
return l->last;
|
||||
}
|
||||
|
||||
struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length) {
|
||||
struct list_node *tmp;
|
||||
tmp=l->first;
|
||||
while(tmp!=NULL) {
|
||||
if(!memcmp((char*)tmp->data+offset,elem,length==0?l->keysize:length)) return (tmp);
|
||||
tmp=tmp->next;
|
||||
}
|
||||
return EMPTYLIST;
|
||||
}
|
||||
|
||||
struct list_node *locate_node(struct list *l,void *elem) {
|
||||
return(xlocate_node(l,elem,0,0));
|
||||
}
|
||||
|
||||
void *xlocate_elem(struct list *l,void *elem,int offset,int length) {
|
||||
struct list_node *node=xlocate_node(l,elem,offset,length);
|
||||
return(node==NULL?NULL:node->data);
|
||||
}
|
||||
|
||||
void *locate_elem(struct list *l,void *elem) {
|
||||
return(xlocate_elem(l,elem,0,0));
|
||||
}
|
||||
|
||||
void flush_list(struct list *l) {
|
||||
struct list_node *tmp;
|
||||
while(l->first!=EMPTYLIST) {
|
||||
tmp=l->first;
|
||||
l->first=l->first->next;
|
||||
free(tmp);
|
||||
tmp=NULL;
|
||||
}
|
||||
l->last=EMPTYLIST;
|
||||
l->count=0;
|
||||
}
|
||||
|
||||
void destroy_list(struct list *l) {
|
||||
struct list_node *tmp;
|
||||
while(l->first!=EMPTYLIST) {
|
||||
tmp=l->first;
|
||||
l->first=l->first->next;
|
||||
free(tmp->data);
|
||||
tmp->data=NULL;
|
||||
free(tmp);
|
||||
tmp=NULL;
|
||||
}
|
||||
l->last=EMPTYLIST;
|
||||
l->count=0;
|
||||
}
|
||||
@ -1,601 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2012, by: Gang Liu <gangban.lau@gmail.com>
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
**********************************************************************
|
||||
*
|
||||
* This is a simple program to limit the cpu usage of a process
|
||||
* If you modify this code, send me a copy please
|
||||
*
|
||||
* Date: 30/8/2008
|
||||
* Version: 1.2 beta
|
||||
* Get the latest version at: http://cpulimit.sourceforge.net
|
||||
*
|
||||
* Changelog from 1.1:
|
||||
* - reorganization of the code, splitted in more source files
|
||||
* - cpu count detection, i.e. if you have 4 cpu, it is possible to limit up to 400%
|
||||
* - in order to avoid deadlocks, cpulimit now prevents to limit itself
|
||||
* - option --path eliminated, use --exe instead both for absolute path and file name
|
||||
* - call setpriority() just once in limit_process()
|
||||
* - no more segmentation fault when processes exit
|
||||
* - no more memory corruption when processes exit
|
||||
* - cpulimit exits if --lazy option is specified and the process terminates
|
||||
* - target process can be created on-fly given command line
|
||||
* - light and scalable algorithm for subprocesses detection and limitation
|
||||
* - mac os support
|
||||
* - minor enhancements and bugfixes
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "process.h"
|
||||
#include "procutils.h"
|
||||
#include "list.h"
|
||||
|
||||
//some useful macro
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
//control time slot in microseconds
|
||||
//each slot is splitted in a working slice and a sleeping slice
|
||||
//TODO: make it adaptive, based on the actual system load
|
||||
#define TIME_SLOT 100000
|
||||
|
||||
#define MAX_PRIORITY -10
|
||||
|
||||
/* GLOBAL VARIABLES */
|
||||
|
||||
//the "family"
|
||||
struct process_family pf;
|
||||
//pid of cpulimit
|
||||
pid_t cpulimit_pid;
|
||||
//name of this program (maybe cpulimit...)
|
||||
char *program_name;
|
||||
|
||||
//number of cpu
|
||||
int NCPU;
|
||||
|
||||
/* CONFIGURATION VARIABLES */
|
||||
|
||||
//verbose mode
|
||||
int verbose = 0;
|
||||
//lazy mode (exits if there is no process)
|
||||
int lazy = 0;
|
||||
|
||||
static void *memrchr(const void *s, int c, size_t n)
|
||||
{
|
||||
const unsigned char *start = (const unsigned char*)s;
|
||||
const unsigned char *end = (const unsigned char*)s;
|
||||
|
||||
end+=n-1;
|
||||
|
||||
while(end>=start) {
|
||||
if(*end==c)
|
||||
return (void *)end;
|
||||
else
|
||||
end--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//SIGINT and SIGTERM signal handler
|
||||
static void quit(int sig)
|
||||
{
|
||||
//let all the processes continue if stopped
|
||||
struct list_node *node = NULL;
|
||||
for (node=pf.members.first; node!= NULL; node=node->next) {
|
||||
struct process *p = (struct process*)(node->data);
|
||||
kill(p->pid, SIGCONT);
|
||||
process_close(p);
|
||||
}
|
||||
//free all the memory
|
||||
cleanup_process_family(&pf);
|
||||
//fix ^C little problem
|
||||
printf("\r");
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//return t1-t2 in microseconds (no overflow checks, so better watch out!)
|
||||
static inline unsigned long timediff(const struct timeval *t1,const struct timeval *t2)
|
||||
{
|
||||
return (t1->tv_sec - t2->tv_sec) * 1000000 + (t1->tv_usec - t2->tv_usec);
|
||||
}
|
||||
|
||||
static void print_usage(FILE *stream, int exit_code)
|
||||
{
|
||||
fprintf(stream, "Usage: %s [OPTIONS...] TARGET\n", program_name);
|
||||
fprintf(stream, " OPTIONS\n");
|
||||
fprintf(stream, " -l, --limit=N percentage of cpu allowed from 0 to %d (required)\n", 100*NCPU);
|
||||
fprintf(stream, " -v, --verbose show control statistics\n");
|
||||
fprintf(stream, " -z, --lazy exit if there is no target process, or if it dies\n");
|
||||
fprintf(stream, " -i, --ignore-children don't limit children processes\n");
|
||||
fprintf(stream, " -h, --help display this help and exit\n");
|
||||
fprintf(stream, " TARGET must be exactly one of these:\n");
|
||||
fprintf(stream, " -p, --pid=N pid of the process (implies -z)\n");
|
||||
fprintf(stream, " -e, --exe=FILE name of the executable program file or path name\n");
|
||||
fprintf(stream, " COMMAND [ARGS] run this command and limit it (implies -z)\n");
|
||||
fprintf(stream, "\nReport bugs to <marlonx80@hotmail.com>.\n");
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
static void increase_priority() {
|
||||
//find the best available nice value
|
||||
errno = 0; // clear errno first
|
||||
int old_priority = getpriority(PRIO_PROCESS, 0);
|
||||
if (errno)
|
||||
{
|
||||
perror("getpriority failed");
|
||||
return;
|
||||
}
|
||||
int priority = old_priority;
|
||||
while (priority > MAX_PRIORITY && setpriority(PRIO_PROCESS, 0, priority-1) == 0) {
|
||||
priority--;
|
||||
}
|
||||
if (priority != old_priority) {
|
||||
if (verbose) printf("Priority changed to %d\n", priority);
|
||||
}
|
||||
else {
|
||||
if (verbose) printf("Warning: Cannot change priority. Run as root or renice for best results.\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the number of CPUs */
|
||||
static int get_ncpu() {
|
||||
int ncpu = -1;
|
||||
#ifdef _SC_NPROCESSORS_ONLN
|
||||
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
#elif defined __APPLE__
|
||||
int mib[2] = {CTL_HW, HW_NCPU};
|
||||
size_t len = sizeof(ncpu);
|
||||
sysctl(mib, 2, &ncpu, &len, NULL, 0);
|
||||
#endif
|
||||
return ncpu;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <sys/vfs.h>
|
||||
|
||||
static int check_proc()
|
||||
{
|
||||
struct statfs mnt;
|
||||
if (statfs("/proc", &mnt) < 0)
|
||||
return 0;
|
||||
if (mnt.f_type!=0x9fa0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void limit_process(pid_t pid, double limit, int ignore_children)
|
||||
{
|
||||
//slice of the slot in which the process is allowed to run
|
||||
struct timespec twork;
|
||||
//slice of the slot in which the process is stopped
|
||||
struct timespec tsleep;
|
||||
//when the last twork has started
|
||||
struct timeval startwork;
|
||||
//when the last twork has finished
|
||||
struct timeval endwork;
|
||||
//initialization
|
||||
memset(&twork, 0, sizeof(struct timespec));
|
||||
memset(&tsleep, 0, sizeof(struct timespec));
|
||||
memset(&startwork, 0, sizeof(struct timeval));
|
||||
memset(&endwork, 0, sizeof(struct timeval));
|
||||
//last working time in microseconds
|
||||
unsigned long workingtime = 0;
|
||||
//generic list item
|
||||
struct list_node *node;
|
||||
//counter
|
||||
int c = 0;
|
||||
|
||||
//get a better priority
|
||||
//increase_priority();
|
||||
|
||||
//build the family
|
||||
if (create_process_family(&pf, pid) == -1)
|
||||
{
|
||||
printf("create process family failed");
|
||||
return ;
|
||||
}
|
||||
if (ignore_children) {
|
||||
//delete any process with a different pid than the father
|
||||
node = pf.members.first;
|
||||
while (node!=NULL) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (proc->pid != pid)
|
||||
{
|
||||
remove_process_from_family(&pf, proc->pid);
|
||||
node = pf.members.first;
|
||||
continue;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore_children && verbose) printf("Members in the family owned by %d: %d\n", pf.father, pf.members.count);
|
||||
|
||||
//rate at which we are keeping active the processes (range 0-1)
|
||||
//1 means that the process are using all the twork slice
|
||||
double workingrate = -1;
|
||||
while(1) {
|
||||
if (!ignore_children && c%10==0) {
|
||||
//update the process family (checks only for new members)
|
||||
int new_children = update_process_family(&pf);
|
||||
if (verbose && new_children) {
|
||||
printf("%d new children processes detected (", new_children);
|
||||
int j;
|
||||
node = pf.members.last;
|
||||
for (j=0; j<new_children; j++) {
|
||||
printf("%d", ((struct process*)(node->data))->pid);
|
||||
if (j<new_children-1) printf(" ");
|
||||
node = node->previous;
|
||||
}
|
||||
printf(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (pf.members.count==0) {
|
||||
if (verbose) printf("No more processes.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//total cpu actual usage (range 0-1)
|
||||
//1 means that the processes are using 100% cpu
|
||||
double pcpu = -1;
|
||||
|
||||
//estimate how much the controlled processes are using the cpu in the working interval
|
||||
node = pf.members.first;
|
||||
while (node!=NULL) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (proc->is_zombie) {
|
||||
//process is zombie, remove it from family
|
||||
fprintf(stderr,"Process %d is zombie!\n", proc->pid);
|
||||
remove_process_from_family(&pf, proc->pid);
|
||||
node = pf.members.first;
|
||||
continue;
|
||||
}
|
||||
if (process_monitor(proc) != 0) {
|
||||
//process is dead, remove it from family
|
||||
if (verbose) fprintf(stderr,"Process %d dead!\n", proc->pid);
|
||||
remove_process_from_family(&pf, proc->pid);
|
||||
node = pf.members.first;
|
||||
continue;
|
||||
}
|
||||
node = node->next;
|
||||
if (proc->cpu_usage<0) {
|
||||
continue;
|
||||
}
|
||||
if (pcpu<0) pcpu = 0;
|
||||
pcpu += proc->cpu_usage;
|
||||
}
|
||||
|
||||
//adjust work and sleep time slices
|
||||
if (pcpu < 0) {
|
||||
//it's the 1st cycle, initialize workingrate
|
||||
pcpu = limit;
|
||||
workingrate = limit;
|
||||
twork.tv_nsec = TIME_SLOT*limit*1000;
|
||||
}
|
||||
else {
|
||||
//adjust workingrate
|
||||
workingrate = MIN(workingrate / pcpu * limit, 1);
|
||||
twork.tv_nsec = TIME_SLOT*1000*workingrate;
|
||||
}
|
||||
tsleep.tv_nsec = TIME_SLOT*1000-twork.tv_nsec;
|
||||
|
||||
if (verbose) {
|
||||
if (c%200==0)
|
||||
printf("\n%%CPU\twork quantum\tsleep quantum\tactive rate\n");
|
||||
if (c%10==0 && c>0)
|
||||
printf("%0.2lf%%\t%6ld us\t%6ld us\t%0.2lf%%\n",pcpu*100,twork.tv_nsec/1000,tsleep.tv_nsec/1000,workingrate*100);
|
||||
}
|
||||
|
||||
//resume processes
|
||||
node = pf.members.first;
|
||||
while (node!=NULL) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (kill(proc->pid,SIGCONT)!=0) {
|
||||
//process is dead, remove it from family
|
||||
if (verbose) fprintf(stderr,"Process %d dead!\n", proc->pid);
|
||||
remove_process_from_family(&pf, proc->pid);
|
||||
node = pf.members.first;
|
||||
continue;
|
||||
}
|
||||
node=node->next;
|
||||
}
|
||||
|
||||
//now processes are free to run (same working slice for all)
|
||||
gettimeofday(&startwork, NULL);
|
||||
nanosleep(&twork,NULL);
|
||||
gettimeofday(&endwork, NULL);
|
||||
workingtime = timediff(&endwork,&startwork);
|
||||
|
||||
long delay = workingtime-twork.tv_nsec/1000;
|
||||
if (c>0 && delay>10000) {
|
||||
//delay is too much! signal to user?
|
||||
//fprintf(stderr, "%d %ld us\n", c, delay);
|
||||
}
|
||||
|
||||
if (tsleep.tv_nsec>0) {
|
||||
//stop only if tsleep>0, instead it's useless
|
||||
node=pf.members.first;
|
||||
while (node!=NULL) {
|
||||
struct process *proc = (struct process*)(node->data);
|
||||
if (kill(proc->pid,SIGSTOP)!=0) {
|
||||
//process is dead, remove it from family
|
||||
if (verbose) fprintf(stderr,"Process %d dead!\n", proc->pid);
|
||||
remove_process_from_family(&pf, proc->pid);
|
||||
node=pf.members.first;
|
||||
continue;
|
||||
}
|
||||
node=node->next;
|
||||
}
|
||||
//now the processes are sleeping
|
||||
nanosleep(&tsleep,NULL);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
cleanup_process_family(&pf);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
//argument variables
|
||||
const char *exe = NULL;
|
||||
int perclimit = 0;
|
||||
int exe_ok = 0;
|
||||
int pid_ok = 0;
|
||||
int limit_ok = 0;
|
||||
pid_t pid = 0;
|
||||
int ignore_children = 0;
|
||||
|
||||
//get program name
|
||||
char *p=(char*)memrchr(argv[0],(unsigned int)'/',strlen(argv[0]));
|
||||
program_name = p==NULL?argv[0]:(p+1);
|
||||
//get current pid
|
||||
cpulimit_pid = getpid();
|
||||
//get cpu count
|
||||
NCPU = get_ncpu();
|
||||
|
||||
//parse arguments
|
||||
int next_option;
|
||||
int option_index = 0;
|
||||
//A string listing valid short options letters
|
||||
const char* short_options = "+p:e:l:vzih";
|
||||
//An array describing valid long options
|
||||
const struct option long_options[] = {
|
||||
{ "pid", required_argument, NULL, 'p' },
|
||||
{ "exe", required_argument, NULL, 'e' },
|
||||
{ "limit", required_argument, NULL, 'l' },
|
||||
{ "verbose", no_argument, NULL, 'v' },
|
||||
{ "lazy", no_argument, NULL, 'z' },
|
||||
{ "ignore-children", no_argument, NULL, 'i' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
do {
|
||||
next_option = getopt_long(argc, argv, short_options,long_options, &option_index);
|
||||
switch(next_option) {
|
||||
case 'p':
|
||||
pid = atoi(optarg);
|
||||
pid_ok = 1;
|
||||
break;
|
||||
case 'e':
|
||||
exe = optarg;
|
||||
exe_ok = 1;
|
||||
break;
|
||||
case 'l':
|
||||
perclimit = atoi(optarg);
|
||||
limit_ok = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'z':
|
||||
lazy = 1;
|
||||
break;
|
||||
case 'i':
|
||||
ignore_children = 1;
|
||||
break;
|
||||
case 'h':
|
||||
print_usage(stdout, 1);
|
||||
break;
|
||||
case '?':
|
||||
print_usage(stderr, 1);
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
} while(next_option != -1);
|
||||
|
||||
if (pid_ok && (pid<=1 || pid>=65536)) {
|
||||
fprintf(stderr,"Error: Invalid value for argument PID\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
if (pid!=0) {
|
||||
lazy = 1;
|
||||
}
|
||||
|
||||
if (!limit_ok) {
|
||||
fprintf(stderr,"Error: You must specify a cpu limit percentage\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
double limit = perclimit/100.0;
|
||||
if (limit<0 || limit >NCPU) {
|
||||
fprintf(stderr,"Error: limit must be in the range 0-%d00\n", NCPU);
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int command_mode = optind<argc;
|
||||
if (exe_ok + pid_ok + command_mode == 0) {
|
||||
fprintf(stderr,"Error: You must specify one target process, either by name, pid, or command line\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (exe_ok + pid_ok + command_mode > 1) {
|
||||
fprintf(stderr,"Error: You must specify exactly one target process, either by name, pid, or command line\n");
|
||||
print_usage(stderr, 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//all arguments are ok!
|
||||
signal(SIGINT, quit);
|
||||
signal(SIGTERM, quit);
|
||||
|
||||
//print the number of available cpu
|
||||
if (verbose) printf("%d cpu detected\n", NCPU);
|
||||
|
||||
#ifdef __linux__
|
||||
if (!check_proc()) {
|
||||
fprintf(stderr, "procfs is not mounted!\nAborting\n");
|
||||
exit(-2);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (command_mode) {
|
||||
int i;
|
||||
//executable file
|
||||
const char *cmd = argv[optind];
|
||||
//command line arguments
|
||||
char **cmd_args = (char**)malloc((argc-optind+1)*sizeof(char*));
|
||||
if (cmd_args==NULL) exit(2);
|
||||
for (i=0; i<argc-optind; i++) {
|
||||
cmd_args[i] = argv[i+optind];
|
||||
}
|
||||
cmd_args[i] = NULL;
|
||||
|
||||
if (verbose) {
|
||||
printf("Running command: '%s", cmd);
|
||||
for (i=1; i<argc-optind; i++) {
|
||||
printf(" %s", cmd_args[i]);
|
||||
}
|
||||
printf("'\n");
|
||||
}
|
||||
|
||||
int child = fork();
|
||||
if (child < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (child > 0) {
|
||||
//parent code
|
||||
int limiter = fork();
|
||||
if (limiter < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (limiter > 0) {
|
||||
//parent
|
||||
int status_process;
|
||||
int status_limiter;
|
||||
waitpid(child, &status_process, 0);
|
||||
waitpid(limiter, &status_limiter, 0);
|
||||
if (WIFEXITED(status_process)) {
|
||||
if (verbose) printf("Process %d terminated with exit status %d\n", child, (int)WEXITSTATUS(status_process));
|
||||
exit(WEXITSTATUS(status_process));
|
||||
}
|
||||
printf("Process %d terminated abnormally\n", child);
|
||||
exit(status_process);
|
||||
}
|
||||
else {
|
||||
//limiter code
|
||||
if (verbose) printf("Limiting process %d\n",child);
|
||||
limit_process(child, limit, ignore_children);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//target process code
|
||||
int ret = execvp(cmd, cmd_args);
|
||||
//if we are here there was an error, show it
|
||||
perror("Error");
|
||||
exit(ret);
|
||||
}
|
||||
}
|
||||
|
||||
while(1) {
|
||||
//look for the target process..or wait for it
|
||||
pid_t ret = 0;
|
||||
if (pid_ok) {
|
||||
//search by pid
|
||||
ret = look_for_process_by_pid(pid);
|
||||
if (ret == 0) {
|
||||
printf("No process found\n");
|
||||
}
|
||||
else if (ret < 0) {
|
||||
printf("Process found but you aren't allowed to control it\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
//search by file or path name
|
||||
ret = look_for_process_by_name(exe);
|
||||
if (ret == 0) {
|
||||
printf("No process found\n");
|
||||
}
|
||||
else if (ret < 0) {
|
||||
printf("Process found but you aren't allowed to control it\n");
|
||||
}
|
||||
else {
|
||||
pid = ret;
|
||||
}
|
||||
}
|
||||
if (ret > 0) {
|
||||
if (ret == cpulimit_pid) {
|
||||
printf("Process %d is cpulimit itself! Aborting to avoid deadlock\n", ret);
|
||||
exit(1);
|
||||
}
|
||||
printf("Process %d found\n", pid);
|
||||
//control
|
||||
limit_process(pid, limit, ignore_children);
|
||||
}
|
||||
if (lazy) break;
|
||||
sleep(2);
|
||||
};
|
||||
|
||||
exit(0);
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
###############################################################################
|
||||
# Gather all flags.
|
||||
#
|
||||
CFLAGS+=-DPOSIXLY_CORRECT -Wall -g
|
||||
|
||||
TARGET=cpulimit-ng
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
SOURCES = $(wildcard *.c)
|
||||
OBJS = $(patsubst %.c,%.o, $(SOURCES))
|
||||
|
||||
$(TARGET) : $(OBJS)
|
||||
$(CC) `for X in $(OBJS) ; do echo "$$X"; done` -o $(TARGET) $(LIBS) $(LDFLAGS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -f *.o $(TARGET)
|
||||
@ -1,76 +0,0 @@
|
||||
##############################################
|
||||
# OpenWrt Makefile for cpulimit-ng program
|
||||
#
|
||||
#
|
||||
# Most of the variables used here are defined in
|
||||
# the include directives below. We just need to
|
||||
# specify a basic description of the package,
|
||||
# where to build our program, where to find
|
||||
# the source files, and where to install the
|
||||
# compiled program on the router.
|
||||
#
|
||||
# Be very careful of spacing in this file.
|
||||
# Indents should be tabs, not spaces, and
|
||||
# there should be no trailing whitespace in
|
||||
# lines that are not commented.
|
||||
#
|
||||
##############################################
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
# Name and release number of this package
|
||||
PKG_NAME:=cpulimit-ng
|
||||
PKG_VERSION:=1.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
# This specifies the directory where we're going to build the program.
|
||||
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
|
||||
# directory in your OpenWrt SDK directory
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
# Specify package information for this program.
|
||||
# The variables defined here should be self explanatory.
|
||||
define Package/cpulimit-ng
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=CPU Usage Limiter for Linux
|
||||
description:=\
|
||||
cpulimit-ng is a simple program which attempts to \\\
|
||||
limit the cpu usage of a process (expressed in \\\
|
||||
percentage, not in cpu time).
|
||||
endef
|
||||
|
||||
# Specify what needs to be done to prepare for building the package.
|
||||
# In our case, we need to copy the source files to the build directory.
|
||||
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
|
||||
# PKG_SOURCE which is not defined here to download the source from the web.
|
||||
# In order to just build a simple program that we have just written, it is
|
||||
# much easier to do it this way.
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
# We do not need to define Build/Configure or Build/Compile directives
|
||||
# The defaults are appropriate for compiling a simple program such as this one
|
||||
|
||||
# Specify where and how to install the program. Since we only have one file,
|
||||
# the cpulimit-ng executable, install it by copying it to the /bin directory on
|
||||
# the router. The $(1) variable represents the root directory on the router running
|
||||
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
|
||||
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
|
||||
# command to copy the binary file from its current location (in our case the build
|
||||
# directory) to the install directory.
|
||||
define Package/cpulimit-ng/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cpulimit-ng $(1)/bin/
|
||||
endef
|
||||
|
||||
# This line executes the necessary commands to compile our program.
|
||||
# The above define directives specify all the information needed, but this
|
||||
# line calls BuildPackage which in turn actually uses this information to
|
||||
# build a package.
|
||||
$(eval $(call BuildPackage,cpulimit-ng))
|
||||
|
||||
@ -1,94 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCUTILS_H
|
||||
|
||||
#define __PROCUTILS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "process.h"
|
||||
|
||||
#define PIDHASH_SZ 1024
|
||||
#define pid_hashfn(x) ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
|
||||
|
||||
// a hierarchy of processes
|
||||
struct process_family {
|
||||
//the (god)father of the process family
|
||||
pid_t father;
|
||||
//process list (father process is the first element)
|
||||
//elements are struct process
|
||||
struct list members;
|
||||
//non-members list
|
||||
//hashtable with all the processes (array of struct list of struct process)
|
||||
struct list *proctable[PIDHASH_SZ];
|
||||
//total process count
|
||||
int count;
|
||||
};
|
||||
|
||||
//TODO: use this object in proctable and delete member in struct process
|
||||
struct table_item {
|
||||
struct process *proc;
|
||||
//1 if the process is a member of the family
|
||||
int member;
|
||||
};
|
||||
|
||||
// object to enumerate running processes
|
||||
struct process_iterator {
|
||||
#ifdef __linux__
|
||||
DIR *dip;
|
||||
struct dirent *dit;
|
||||
#elif defined __APPLE__
|
||||
struct kinfo_proc *procList;
|
||||
int count;
|
||||
int c;
|
||||
#elif defined __hpux
|
||||
int count;
|
||||
#endif
|
||||
struct process *current;
|
||||
};
|
||||
|
||||
// searches for all the processes derived from father and stores them
|
||||
// in the process family struct
|
||||
int create_process_family(struct process_family *f, pid_t father);
|
||||
|
||||
// checks if there are new processes born in the specified family
|
||||
// if any they are added to the members list
|
||||
// the number of new born processes is returned
|
||||
int update_process_family(struct process_family *f);
|
||||
|
||||
// removes a process from the family by its pid
|
||||
void remove_process_from_family(struct process_family *f, pid_t pid);
|
||||
|
||||
// free the heap memory used by a process family
|
||||
void cleanup_process_family(struct process_family *f);
|
||||
|
||||
// searches a process given the name of the executable file, or its absolute path
|
||||
// returns the pid, or 0 if it's not found
|
||||
int look_for_process_by_name(const char *process_name);
|
||||
|
||||
// searches a process given its pid
|
||||
// returns the pid, or 0 if it's not found
|
||||
int look_for_process_by_pid(pid_t pid);
|
||||
|
||||
#endif
|
||||
@ -1,2 +0,0 @@
|
||||
based on cpulimit@sf svn version revision 41
|
||||
Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
@ -1,88 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PROCESS_H
|
||||
|
||||
#define __PROCESS_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
//USER_HZ detection, from openssl code
|
||||
#ifndef HZ
|
||||
# if defined(_SC_CLK_TCK) \
|
||||
&& (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
|
||||
# define HZ ((double)sysconf(_SC_CLK_TCK))
|
||||
# else
|
||||
# ifndef CLK_TCK
|
||||
# ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
|
||||
# define HZ 100.0
|
||||
# else /* _BSD_CLK_TCK_ */
|
||||
# define HZ ((double)_BSD_CLK_TCK_)
|
||||
# endif
|
||||
# else /* CLK_TCK */
|
||||
# define HZ ((double)CLK_TCK)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// process descriptor
|
||||
struct process {
|
||||
//pid of the process
|
||||
pid_t pid;
|
||||
//pid of the process
|
||||
pid_t ppid;
|
||||
//start time
|
||||
int starttime;
|
||||
//is member of the family?
|
||||
int member; //TODO: delete this field
|
||||
//total number of jiffies used by the process at time last_sample
|
||||
int last_jiffies;
|
||||
//timestamp when last_jiffies and cpu_usage was calculated
|
||||
struct timeval last_sample;
|
||||
//actual cpu usage estimation (value in range 0-1)
|
||||
double cpu_usage;
|
||||
//1 if the process is zombie
|
||||
int is_zombie;
|
||||
//absolute path of the executable file
|
||||
char command[PATH_MAX+1];
|
||||
|
||||
//system-dependent members
|
||||
//TODO: delete these members for the sake of portability?
|
||||
#ifdef __linux__
|
||||
//preallocate buffers for performance
|
||||
//name of /proc/PID/stat file
|
||||
char stat_file[20];
|
||||
//read buffer for /proc filesystem
|
||||
char buffer[1024];
|
||||
#endif
|
||||
};
|
||||
|
||||
int get_proc_info(struct process *p, pid_t pid);
|
||||
|
||||
int process_init(struct process *proc, pid_t pid);
|
||||
|
||||
int process_monitor(struct process *proc);
|
||||
|
||||
int process_close(struct process *proc);
|
||||
|
||||
#endif
|
||||
@ -1,283 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2012, by: Gang Liu <gangban.lau@gmail.com>
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
//TODO: add documentation to public functions
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "process.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/sysctl.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
int get_proc_info(struct process *p, pid_t pid) {
|
||||
/* static char statfile[20];
|
||||
static char buffer[64];
|
||||
int ret;
|
||||
sprintf(statfile, "/proc/%d/stat", pid);
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd==NULL) return -1;
|
||||
fgets(buffer, sizeof(buffer), fd);
|
||||
fclose(fd);
|
||||
|
||||
char state;
|
||||
|
||||
int n = sscanf(buffer, "%d %s %c %d %d %d %d %d "
|
||||
"%lu %lu %lu %lu %lu %lu %lu "
|
||||
"%ld %ld %ld %ld %ld %ld "
|
||||
"%lu ",
|
||||
&p->pid,
|
||||
&p->command,
|
||||
&state,
|
||||
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
|
||||
&utime,&stime,&cutime,&cstime,
|
||||
NULL,NULL,NULL,NULL,
|
||||
&starttime,
|
||||
);*/
|
||||
return 0;
|
||||
}
|
||||
#elif defined __APPLE__
|
||||
int get_proc_info(struct process *p, pid_t pid) {
|
||||
int err;
|
||||
struct kinfo_proc *result = NULL;
|
||||
size_t length;
|
||||
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
|
||||
|
||||
/* We start by calling sysctl with result == NULL and length == 0.
|
||||
That will succeed, and set length to the appropriate length.
|
||||
We then allocate a buffer of that size and call sysctl again
|
||||
with that buffer.
|
||||
*/
|
||||
length = 0;
|
||||
err = sysctl(mib, 4, NULL, &length, NULL, 0);
|
||||
if (err == -1) {
|
||||
err = errno;
|
||||
}
|
||||
if (err == 0) {
|
||||
result = malloc(length);
|
||||
err = sysctl(mib, 4, result, &length, NULL, 0);
|
||||
if (err == -1)
|
||||
err = errno;
|
||||
if (err == ENOMEM) {
|
||||
free(result); /* clean up */
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
p->pid = result->kp_proc.p_pid;
|
||||
p->ppid = result->kp_eproc.e_ppid;
|
||||
p->starttime = result->kp_proc.p_starttime.tv_sec;
|
||||
p->last_jiffies = result->kp_proc.p_cpticks;
|
||||
//p_pctcpu
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
// TODO man 5 proc, scanf, see above get_proc_info
|
||||
static char * get_proc_stat_field(const char * statfile, int idx)
|
||||
{
|
||||
char buffer[1024];
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd==NULL)
|
||||
{
|
||||
perror("open process stat file failed");
|
||||
return NULL;
|
||||
}
|
||||
if (fgets(buffer, sizeof(buffer), fd) == NULL)
|
||||
{
|
||||
perror("read process stat file failed");
|
||||
fclose(fd);
|
||||
return NULL;
|
||||
}
|
||||
fclose(fd);
|
||||
|
||||
char *p = buffer;
|
||||
int slen = strlen(buffer);
|
||||
int sp = idx;
|
||||
while (sp-- && p != NULL && (p+1) < (buffer + slen))
|
||||
p = strchr(p+1, ' ');
|
||||
if (p==NULL || (p+1) >= (buffer + slen))
|
||||
{
|
||||
printf("process stat file format error");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *q = strchr(p+1, ' ');
|
||||
if (q==NULL)
|
||||
{
|
||||
printf("process stat file format error");
|
||||
return NULL;
|
||||
}
|
||||
*q = '\0';
|
||||
char *item = (char *)malloc(strlen(p+1) + 1);
|
||||
if (item != NULL)
|
||||
{
|
||||
snprintf(item, strlen(p+1) + 1, "%s", p+1);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// returns the start time of a process (used with pid to identify a process)
|
||||
static unsigned long long get_starttime(pid_t pid)
|
||||
{
|
||||
#ifdef __linux__
|
||||
char file[20];
|
||||
snprintf(file, sizeof(file), "/proc/%d/stat", pid);
|
||||
//start time of the process
|
||||
char *tbuf = get_proc_stat_field(file, 21);
|
||||
if (tbuf == NULL)
|
||||
return -1;
|
||||
unsigned long long starttime = 0;
|
||||
sscanf(tbuf, "%llu", &starttime);
|
||||
free(tbuf);
|
||||
return starttime;
|
||||
#elif defined __APPLE__
|
||||
struct process proc;
|
||||
get_proc_info(&proc, pid);
|
||||
return proc.starttime;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int get_jiffies(struct process *proc) {
|
||||
#ifdef __linux__
|
||||
//user mode jiffies
|
||||
char *tbuf = get_proc_stat_field(proc->stat_file, 13);
|
||||
if (tbuf==NULL)
|
||||
return -1;
|
||||
unsigned long utime = 0;
|
||||
sscanf(tbuf, "%lu", &utime);
|
||||
free(tbuf);
|
||||
//kernel mode jiffies
|
||||
tbuf = get_proc_stat_field(proc->stat_file, 14);
|
||||
if (tbuf==NULL)
|
||||
return -1;
|
||||
unsigned long stime = 0;
|
||||
sscanf(tbuf, "%lu", &stime);
|
||||
free(tbuf);
|
||||
return utime+stime;
|
||||
#elif defined __APPLE__
|
||||
struct process proc2;
|
||||
get_proc_info(&proc2, proc->pid);
|
||||
return proc2.last_jiffies;
|
||||
#endif
|
||||
}
|
||||
|
||||
//return t1-t2 in microseconds (no overflow checks, so better watch out!)
|
||||
static inline unsigned long timediff(const struct timeval *t1,const struct timeval *t2)
|
||||
{
|
||||
return (t1->tv_sec - t2->tv_sec) * 1000000 + (t1->tv_usec - t2->tv_usec);
|
||||
}
|
||||
|
||||
/*static int*/ int process_update(struct process *proc) {
|
||||
//TODO: get any process statistic here
|
||||
//check that starttime is not changed(?), update jiffies, parent, zombie status
|
||||
return 0;
|
||||
}
|
||||
|
||||
int process_init(struct process *proc, int pid)
|
||||
{
|
||||
//general members
|
||||
proc->pid = pid;
|
||||
proc->starttime = get_starttime(pid);
|
||||
if (proc->starttime == -1)
|
||||
return -1;
|
||||
//printf("process starttime %d\n", proc->starttime);
|
||||
proc->cpu_usage = 0;
|
||||
memset(&(proc->last_sample), 0, sizeof(struct timeval));
|
||||
proc->last_jiffies = -1;
|
||||
proc->is_zombie = 0;
|
||||
//system dependent members
|
||||
#ifdef __linux__
|
||||
//TODO: delete these members for the sake of portability?
|
||||
//test /proc file descriptor for reading
|
||||
snprintf(proc->stat_file, sizeof(proc->stat_file), "/proc/%d/stat", pid);
|
||||
// FILE *fd = fopen(proc->stat_file, "r");
|
||||
// if (fd == NULL) return 1;
|
||||
// fclose(fd);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
//parameter in range 0-1
|
||||
#define ALFA 0.08
|
||||
|
||||
int process_monitor(struct process *proc)
|
||||
{
|
||||
int j = get_jiffies(proc);
|
||||
if (j<0) return -1; //error retrieving jiffies count (maybe the process is dead)
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
if (proc->last_jiffies==-1) {
|
||||
//store current time
|
||||
proc->last_sample.tv_sec = now.tv_sec;
|
||||
proc->last_sample.tv_usec = now.tv_usec;
|
||||
//store current jiffies
|
||||
proc->last_jiffies = j;
|
||||
//it's the first sample, cannot figure out the cpu usage
|
||||
proc->cpu_usage = -1;
|
||||
return 0;
|
||||
}
|
||||
//time from previous sample (in ns)
|
||||
long dt = timediff(&now, &(proc->last_sample));
|
||||
//how many jiffies in dt?
|
||||
double max_jiffies = dt * HZ / 1000000.0;
|
||||
double sample = (j - proc->last_jiffies) / max_jiffies;
|
||||
if (proc->cpu_usage == -1) {
|
||||
//initialization
|
||||
proc->cpu_usage = sample;
|
||||
}
|
||||
else {
|
||||
//usage adjustment
|
||||
proc->cpu_usage = (1-ALFA) * proc->cpu_usage + ALFA * sample;
|
||||
}
|
||||
|
||||
//store current time
|
||||
proc->last_sample.tv_sec = now.tv_sec;
|
||||
proc->last_sample.tv_usec = now.tv_usec;
|
||||
//store current jiffies
|
||||
proc->last_jiffies = j;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int process_close(struct process *proc)
|
||||
{
|
||||
if (kill(proc->pid,SIGCONT)!=0) {
|
||||
fprintf(stderr,"Process %d is already dead!\n", proc->pid);
|
||||
}
|
||||
proc->pid = 0;
|
||||
return 0;
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
**********************************************************************
|
||||
*
|
||||
* Dynamic list interface
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LIST__
|
||||
|
||||
#define __LIST__
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
struct list_node {
|
||||
//pointer to the content of the node
|
||||
void *data;
|
||||
//pointer to previous node
|
||||
struct list_node *previous;
|
||||
//pointer to next node
|
||||
struct list_node *next;
|
||||
};
|
||||
|
||||
struct list {
|
||||
//first node
|
||||
struct list_node *first;
|
||||
//last node
|
||||
struct list_node *last;
|
||||
//size of the search key in bytes
|
||||
int keysize;
|
||||
//element count
|
||||
int count;
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize a list, with a specified key size
|
||||
*/
|
||||
void init_list(struct list *l,int keysize);
|
||||
|
||||
/*
|
||||
* Add a new element at the end of the list
|
||||
* return the pointer to the new node
|
||||
*/
|
||||
struct list_node *add_elem(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* Delete a node
|
||||
*/
|
||||
void delete_node(struct list *l,struct list_node *node);
|
||||
|
||||
/*
|
||||
* Delete a node from the list, even the content pointed by it
|
||||
* Use only when the content is a dynamically allocated pointer
|
||||
*/
|
||||
void destroy_node(struct list *l,struct list_node *node);
|
||||
|
||||
/*
|
||||
* Check whether a list is empty or not
|
||||
*/
|
||||
int is_empty_list(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the element count of the list
|
||||
*/
|
||||
int get_list_count(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the first element (content of the node) from the list
|
||||
*/
|
||||
void *first_elem(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the first node from the list
|
||||
*/
|
||||
struct list_node *first_node(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the last element (content of the node) from the list
|
||||
*/
|
||||
void *last_elem(struct list *l);
|
||||
|
||||
/*
|
||||
* Return the last node from the list
|
||||
*/
|
||||
struct list_node *last_node(struct list *l);
|
||||
|
||||
/*
|
||||
* Search an element of the list by content
|
||||
* the comparison is done from the specified offset and for a specified length
|
||||
* if offset=0, the comparison starts from the address pointed by data
|
||||
* if length=0, default keysize is used for length
|
||||
* if the element is found, return the node address
|
||||
* else return NULL
|
||||
*/
|
||||
struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length);
|
||||
|
||||
/*
|
||||
* The same of xlocate_node(), but return the content of the node
|
||||
*/
|
||||
void *xlocate_elem(struct list *l,void *elem,int offset,int length);
|
||||
|
||||
/*
|
||||
* The same of calling xlocate_node() with offset=0 and length=0
|
||||
*/
|
||||
struct list_node *locate_node(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* The same of locate_node, but return the content of the node
|
||||
*/
|
||||
void *locate_elem(struct list *l,void *elem);
|
||||
|
||||
/*
|
||||
* Delete all the elements in the list
|
||||
*/
|
||||
void flush_list(struct list *l);
|
||||
|
||||
/*
|
||||
* Delete every element in the list, and free the memory pointed by all the node data
|
||||
*/
|
||||
void destroy_list(struct list *l);
|
||||
|
||||
#endif
|
||||
@ -1,544 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* cpulimit - a cpu limiter for Linux
|
||||
*
|
||||
* Copyright (C) 2012, by: Gang Liu <gangban.lau@gmail.com>
|
||||
* Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
*
|
||||
* This program 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 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "procutils.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/sysctl.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* PROCESS STATISTICS FUNCTIONS */
|
||||
|
||||
//deprecated
|
||||
// returns pid of the parent process
|
||||
static pid_t getppid_of(pid_t pid)
|
||||
{
|
||||
#ifdef __linux__
|
||||
char file[20];
|
||||
char buffer[1024];
|
||||
snprintf(file, sizeof(file), "/proc/%d/stat", pid);
|
||||
FILE *fd = fopen(file, "r");
|
||||
if (fd==NULL) return -1;
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL)
|
||||
{
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
fclose(fd);
|
||||
char *p = buffer;
|
||||
p = memchr(p+1,')', sizeof(buffer) - (p-buffer));
|
||||
int sp = 2;
|
||||
while (sp--)
|
||||
p = memchr(p+1,' ',sizeof(buffer) - (p-buffer));
|
||||
//pid of the parent process
|
||||
pid_t ppid = atoi(p+1);
|
||||
return ppid;
|
||||
#elif defined __APPLE__
|
||||
struct process p;
|
||||
get_proc_info(&p, pid);
|
||||
return p.ppid;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// detects whether a process is a kernel thread or not
|
||||
static int is_kernel_thread(pid_t pid)
|
||||
{
|
||||
char statfile[20];
|
||||
char buffer[64];
|
||||
int ret;
|
||||
snprintf(statfile, sizeof(statfile), "/proc/%d/statm", pid);
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd==NULL)
|
||||
{
|
||||
perror("open process statm file failed");
|
||||
return -1;
|
||||
}
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL)
|
||||
{
|
||||
perror("read process statm file failed");
|
||||
fclose(fd);
|
||||
return -1;
|
||||
}
|
||||
ret = strncmp(buffer,"0 0 0",3)==0;
|
||||
fclose(fd);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
//deprecated
|
||||
// returns 1 if pid is an existing pid, 0 otherwise
|
||||
static int process_exists(pid_t pid) {
|
||||
#ifdef __linux__
|
||||
char procdir[20];
|
||||
struct stat procstat;
|
||||
snprintf(procdir, sizeof(procdir), "/proc/%d", pid);
|
||||
return stat(procdir, &procstat)==0;
|
||||
#elif defined __APPLE__
|
||||
struct process p;
|
||||
return get_proc_info(&p, pid)==0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* PID HASH FUNCTIONS */
|
||||
|
||||
static int hash_process(struct process_family *f, struct process *p)
|
||||
{
|
||||
int ret;
|
||||
struct list **l = &(f->proctable[pid_hashfn(p->pid)]);
|
||||
if (*l == NULL) {
|
||||
//there is no process in this hashtable item
|
||||
//allocate the list
|
||||
*l = (struct list*)malloc(sizeof(struct list));
|
||||
init_list(*l, 4);
|
||||
add_elem(*l, p);
|
||||
ret = 0;
|
||||
f->count++;
|
||||
}
|
||||
else {
|
||||
//list already exists
|
||||
struct process *tmp = (struct process*)locate_elem(*l, p);
|
||||
if (tmp != NULL) {
|
||||
//update process info
|
||||
memcpy(tmp, p, sizeof(struct process));
|
||||
free(p);
|
||||
p = NULL;
|
||||
ret = 1;
|
||||
}
|
||||
else {
|
||||
//add new process
|
||||
add_elem(*l, p);
|
||||
ret = 0;
|
||||
f->count++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void unhash_process(struct process_family *f, pid_t pid) {
|
||||
//remove process from hashtable
|
||||
struct list **l = &(f->proctable[pid_hashfn(pid)]);
|
||||
if (*l == NULL)
|
||||
return; //nothing done
|
||||
struct list_node *node = locate_node(*l, &pid);
|
||||
if (node != NULL)
|
||||
destroy_node(*l, node);
|
||||
f->count--;
|
||||
}
|
||||
|
||||
static struct process *seek_process(struct process_family *f, pid_t pid)
|
||||
{
|
||||
struct list **l = &(f->proctable[pid_hashfn(pid)]);
|
||||
return (*l != NULL) ? (struct process*)locate_elem(*l, &pid) : NULL;
|
||||
}
|
||||
|
||||
/* PROCESS ITERATOR STUFF */
|
||||
|
||||
// creates an object that browse all running processes
|
||||
int init_process_iterator(struct process_iterator *i) {
|
||||
#ifdef __linux__
|
||||
//open a directory stream to /proc directory
|
||||
if ((i->dip = opendir("/proc")) == NULL) {
|
||||
perror("opendir");
|
||||
return -1;
|
||||
}
|
||||
#elif defined __APPLE__
|
||||
|
||||
int err;
|
||||
struct kinfo_proc *result = NULL;
|
||||
size_t length;
|
||||
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
|
||||
|
||||
/* We start by calling sysctl with result == NULL and length == 0.
|
||||
That will succeed, and set length to the appropriate length.
|
||||
We then allocate a buffer of that size and call sysctl again
|
||||
with that buffer.
|
||||
*/
|
||||
length = 0;
|
||||
err = sysctl(mib, 4, NULL, &length, NULL, 0);
|
||||
if (err == -1) {
|
||||
err = errno;
|
||||
}
|
||||
if (err == 0) {
|
||||
result = malloc(length);
|
||||
err = sysctl(mib, 4, result, &length, NULL, 0);
|
||||
if (err == -1)
|
||||
err = errno;
|
||||
if (err == ENOMEM) {
|
||||
free(result); /* clean up */
|
||||
result = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
i->procList = result;
|
||||
i->count = err == 0 ? length / sizeof *result : 0;
|
||||
i->c = 0;
|
||||
|
||||
#endif
|
||||
i->current = (struct process*)malloc(sizeof(struct process));
|
||||
if (i->current == NULL)
|
||||
{
|
||||
perror("malloc falied");
|
||||
closedir(i->dip);
|
||||
return -1;
|
||||
}
|
||||
memset(i->current, 0, sizeof(struct process));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// reads the next user process from /process
|
||||
// automatic closing if the end of the list is reached
|
||||
int read_next_process(struct process_iterator *i) {
|
||||
#ifdef __linux__
|
||||
pid_t pid = 0;
|
||||
//TODO read this to port to other systems: http://www.steve.org.uk/Reference/Unix/faq_8.html#SEC85
|
||||
//read in from /proc and seek for process dirs
|
||||
while ((i->dit = readdir(i->dip)) != NULL) {
|
||||
if(strtok(i->dit->d_name, "0123456789") != NULL)
|
||||
continue;
|
||||
pid = atoi(i->dit->d_name);
|
||||
if (is_kernel_thread(pid))
|
||||
{
|
||||
pid = 0;
|
||||
continue;
|
||||
}
|
||||
//return the first found process
|
||||
break;
|
||||
}
|
||||
if (pid == 0) {
|
||||
//no more processes
|
||||
closedir(i->dip);
|
||||
i->dip = NULL;
|
||||
free(i->current);
|
||||
i->current = NULL;
|
||||
return -1;
|
||||
}
|
||||
//read the executable link
|
||||
char statfile[20];
|
||||
snprintf(statfile, sizeof(statfile), "/proc/%d/cmdline",pid);
|
||||
FILE *fd = fopen(statfile, "r");
|
||||
if (fd == NULL)
|
||||
{
|
||||
perror("open process cmdline file failed");
|
||||
return -1;
|
||||
}
|
||||
char buffer[1024];
|
||||
if (fgets(buffer, sizeof(buffer), fd)==NULL)
|
||||
{
|
||||
perror("read process cmdline file falied");
|
||||
fclose(fd);
|
||||
return -2;
|
||||
}
|
||||
fclose(fd);
|
||||
sscanf(buffer, "%s", (char*)&i->current->command);
|
||||
i->current->pid = pid;
|
||||
|
||||
#elif defined __APPLE__
|
||||
if (i->c >= i->count) {
|
||||
//no more processes
|
||||
free(i->procList);
|
||||
i->procList = NULL;
|
||||
free(i->current);
|
||||
i->current = NULL;
|
||||
return -1;
|
||||
}
|
||||
i->current->pid = i->procList[i->c].kp_proc.p_pid;
|
||||
strncpy(i->current->command, i->procList[i->c].kp_proc.p_comm, MAXCOMLEN);
|
||||
printf("%d %d %s\n", i->c, i->current->pid, i->current->command);//i->procList[i->c].kp_proc.p_comm);
|
||||
//printf("%d %d %s\n", i->c, i->current->pid, i->proc[i->c].kp_proc.p_comm);
|
||||
i->c++;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* PUBLIC FUNCTIONS */
|
||||
|
||||
// search for all the processes derived from father and stores them
|
||||
// in the process family struct
|
||||
int create_process_family(struct process_family *f, pid_t father)
|
||||
{
|
||||
//process iterator
|
||||
struct process_iterator iter;
|
||||
if (init_process_iterator(&iter) == -1)
|
||||
return -1;
|
||||
|
||||
//process list initialization (4 bytes key)
|
||||
init_list(&(f->members), 4);
|
||||
//hashtable initialization
|
||||
memset(&(f->proctable), 0, sizeof(f->proctable));
|
||||
f->count = 0;
|
||||
f->father = father;
|
||||
|
||||
int pid = 0;
|
||||
while (read_next_process(&iter)==0) {
|
||||
pid = iter.current->pid;
|
||||
//check if process belongs to the family
|
||||
int ppid = pid;
|
||||
//TODO: optimize adding also these parents, and continue if process is already present
|
||||
while(ppid!=1 && ppid!=father) {
|
||||
//pid_t f = getppid(ppid);
|
||||
ppid = getppid_of(ppid);
|
||||
//printf("p1 %d, p2 %d\n", f, ppid);
|
||||
}
|
||||
//allocate process descriptor
|
||||
struct process *p = (struct process*)malloc(sizeof(struct process));
|
||||
//init process
|
||||
if (process_init(p, pid) == -1)
|
||||
{
|
||||
printf("init process failed\n");
|
||||
free(p);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ppid==1) {
|
||||
//the init process
|
||||
p->member = 0;
|
||||
}
|
||||
else if (pid != getpid()) {
|
||||
//add to members (but exclude the current cpulimit process!)
|
||||
p->member = 1;
|
||||
add_elem(&(f->members), p);
|
||||
}
|
||||
//add to hashtable
|
||||
hash_process(f, p);
|
||||
}
|
||||
|
||||
if (iter.dip != NULL)
|
||||
closedir(iter.dip);
|
||||
if (iter.current != NULL)
|
||||
free(iter.current);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checks if there are new processes born in the specified family
|
||||
// if any they are added to the members list
|
||||
// the number of new born processes is returned
|
||||
int update_process_family(struct process_family *f)
|
||||
{
|
||||
//process iterator
|
||||
struct process_iterator iter;
|
||||
if (init_process_iterator(&iter) == -1)
|
||||
return -1;
|
||||
int ret = 0;
|
||||
int pid = 0;
|
||||
while (read_next_process(&iter)==0) {
|
||||
pid = iter.current->pid;
|
||||
struct process *newp = seek_process(f, pid);
|
||||
if (newp != NULL) continue; //already known //TODO: what if newp is a new process with the same PID??
|
||||
//the process is new, check if it belongs to the family
|
||||
int ppid = getppid_of(pid);
|
||||
//search the youngest known ancestor of the process
|
||||
struct process *ancestor = NULL;
|
||||
while((ancestor=seek_process(f, ppid))==NULL) {
|
||||
ppid = getppid_of(ppid);
|
||||
}
|
||||
if (ancestor == NULL) {
|
||||
//this should never happen! if does, find and correct the bug
|
||||
fprintf(stderr, "Fatal bug! Process %d is without parent\n", pid);
|
||||
exit(1);
|
||||
}
|
||||
//allocate and insert the process
|
||||
struct process *p = (struct process*)malloc(sizeof(struct process));
|
||||
//init process
|
||||
if (process_init(p, pid) == -1)
|
||||
{
|
||||
printf("init process failed\n");
|
||||
free(p);
|
||||
continue;
|
||||
}
|
||||
if (ancestor->member) {
|
||||
//add to members
|
||||
p->member = 1;
|
||||
add_elem(&(f->members), p);
|
||||
ret++;
|
||||
}
|
||||
else {
|
||||
//not a member
|
||||
p->member = 0;
|
||||
}
|
||||
//add to hashtable
|
||||
hash_process(f, p);
|
||||
}
|
||||
|
||||
if (iter.dip != NULL)
|
||||
closedir(iter.dip);
|
||||
if (iter.current != NULL)
|
||||
free(iter.current);
|
||||
|
||||
// remove non-member process if exited
|
||||
struct list pid_list;
|
||||
init_list(&pid_list, 0);
|
||||
int i;
|
||||
struct list_node *node = NULL;
|
||||
int size = sizeof(f->proctable) / sizeof(struct process*);
|
||||
for (i=0; i<size; i++) {
|
||||
if (f->proctable[i] != NULL) {
|
||||
for (node=f->proctable[i]->first; node!=NULL; node=node->next) {
|
||||
struct process *p = (struct process*)(node->data);
|
||||
if (!p->member && !process_exists(p->pid))
|
||||
add_elem(&pid_list, &p->pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (node=pid_list.first; node!=NULL; node=node->next) {
|
||||
pid_t * p = (pid_t *)(node->data);
|
||||
remove_process_from_family(f, *p);
|
||||
}
|
||||
flush_list(&pid_list);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// removes a process from the family by its pid
|
||||
void remove_process_from_family(struct process_family *f, pid_t pid)
|
||||
{
|
||||
struct list_node *node = locate_node(&(f->members), &pid);
|
||||
if (node != NULL) {
|
||||
// struct process *p = (struct process*)(node->data);
|
||||
// free(p->history);
|
||||
// p->history = NULL;
|
||||
delete_node(&(f->members), node);
|
||||
}
|
||||
unhash_process(f, pid);
|
||||
}
|
||||
|
||||
// free the heap memory used by a process family
|
||||
void cleanup_process_family(struct process_family *f)
|
||||
{
|
||||
int i;
|
||||
int size = sizeof(f->proctable) / sizeof(struct process*);
|
||||
for (i=0; i<size; i++) {
|
||||
if (f->proctable[i] != NULL) {
|
||||
//free() history for each process
|
||||
struct list_node *node = NULL;
|
||||
for (node=f->proctable[i]->first; node!=NULL; node=node->next) {
|
||||
// struct process *p = (struct process*)(node->data);
|
||||
// free(p->history);
|
||||
// p->history = NULL;
|
||||
}
|
||||
destroy_list(f->proctable[i]);
|
||||
free(f->proctable[i]);
|
||||
f->proctable[i] = NULL;
|
||||
}
|
||||
}
|
||||
flush_list(&(f->members));
|
||||
f->count = 0;
|
||||
f->father = 0;
|
||||
}
|
||||
|
||||
// look for a process by pid
|
||||
// search_pid : pid of the wanted process
|
||||
// return: pid of the found process, if it is found
|
||||
// 0, if it's not found
|
||||
// negative pid, if it is found but it's not possible to control it
|
||||
int look_for_process_by_pid(pid_t pid)
|
||||
{
|
||||
if (process_exists(pid))
|
||||
return (kill(pid,0)==0) ? pid : -pid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// look for a process with a given name
|
||||
// process: the name of the wanted process. it can be an absolute path name to the executable file
|
||||
// or just the file name
|
||||
// return: pid of the found process, if it is found
|
||||
// 0, if it's not found
|
||||
// negative pid, if it is found but it's not possible to control it
|
||||
int look_for_process_by_name(const char *process_name)
|
||||
{
|
||||
//whether the variable process_name is the absolute path or not
|
||||
int is_absolute_path = process_name[0] == '/';
|
||||
//flag indicating if the a process with given name was found
|
||||
int found = 0;
|
||||
|
||||
//process iterator
|
||||
struct process_iterator iter;
|
||||
if (init_process_iterator(&iter) == -1)
|
||||
return -1;
|
||||
pid_t pid = 0;
|
||||
|
||||
printf("name\n");
|
||||
|
||||
while (read_next_process(&iter)==0) {
|
||||
pid = iter.current->pid;
|
||||
|
||||
int size = strlen(iter.current->command);
|
||||
|
||||
found = 0;
|
||||
if (is_absolute_path && strncmp(iter.current->command, process_name, size)==0 && size==strlen(process_name)) {
|
||||
//process found
|
||||
found = 1;
|
||||
}
|
||||
else {
|
||||
//process found
|
||||
if (strncmp(iter.current->command + size - strlen(process_name), process_name, strlen(process_name))==0) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if (found==1) {
|
||||
if (kill(pid,SIGCONT)==0) {
|
||||
//process is ok!
|
||||
break;
|
||||
}
|
||||
else {
|
||||
//we don't have permission to send signal to that process
|
||||
//so, don't exit from the loop and look for another one with the same name
|
||||
found = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (iter.dip != NULL)
|
||||
closedir(iter.dip);
|
||||
if (iter.current != NULL)
|
||||
free(iter.current);
|
||||
|
||||
if (found == 1) {
|
||||
//ok, the process was found
|
||||
return pid;
|
||||
}
|
||||
else if (found == 0) {
|
||||
//no process found
|
||||
return 0;
|
||||
}
|
||||
else if (found == -1) {
|
||||
//the process was found, but we haven't permission to control it
|
||||
return -pid;
|
||||
}
|
||||
//this MUST NOT happen
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
Cpulimit 1.2
|
||||
|
||||
=======
|
||||
About
|
||||
=======
|
||||
|
||||
Cpulimit is a program that attempts to limit the cpu usage of a process (expressed in percentage, not in cpu time). It is useful to control batch jobs, when you don't want they eat too much cpu. The goal it to not let a proces run for more than a specified time ratio. It does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.
|
||||
The control of the used cpu amount is done sending properly SIGSTOP and SIGCONT POSIX signals to processes.
|
||||
All the children processes and threads of the specified process will share the same percent of cpu.
|
||||
|
||||
Developed by Angelo Marletta.
|
||||
Please send your feedback, bug reports, feature requests or just thanks :) to marlonx80@hotmail.com.
|
||||
|
||||
=====================
|
||||
Changelog since 1.1
|
||||
=====================
|
||||
|
||||
- reorganization of the code, splitted in more source files
|
||||
- cpu count detection, i.e. if you have 4 cpu, it is possible to limit up to 400%
|
||||
- in order to avoid deadlocks, cpulimit now prevents to limit itself
|
||||
- option --path eliminated, use --exe instead both for absolute path and file name
|
||||
- call setpriority() just once
|
||||
- no more segmentation fault when processes exit
|
||||
- no more memory corruption when processes exit
|
||||
- cpulimit exits if --lazy option is specified and the process terminates
|
||||
- target process can be created on-fly given command line
|
||||
- light and scalable algorithm for subprocesses detection and limitation
|
||||
- mac os support
|
||||
- minor enhancements and bugfixes
|
||||
|
||||
============================
|
||||
Get the latest source code
|
||||
============================
|
||||
|
||||
You can checkout the latest code from sourceforge Subversion repository, running:
|
||||
|
||||
svn checkout https://cpulimit.svn.sourceforge.net/svnroot/cpulimit cpulimit
|
||||
|
||||
Of course this is the development version, so you may experience bugs (please signal them and your soul will be saved!)
|
||||
|
||||
|
||||
==============
|
||||
Installation
|
||||
==============
|
||||
|
||||
Run 'make' and place the executable file 'cpulimit' wherever you want.
|
||||
Type 'cpulimit --help' to get documentation on available options.
|
||||
Binary file not shown.
@ -1,67 +1,27 @@
|
||||
##############################################
|
||||
# OpenWrt Makefile for cpulimit-ng program
|
||||
#
|
||||
#
|
||||
# Most of the variables used here are defined in
|
||||
# the include directives below. We just need to
|
||||
# specify a basic description of the package,
|
||||
# where to build our program, where to find
|
||||
# the source files, and where to install the
|
||||
# compiled program on the router.
|
||||
#
|
||||
# Be very careful of spacing in this file.
|
||||
# Indents should be tabs, not spaces, and
|
||||
# there should be no trailing whitespace in
|
||||
# lines that are not commented.
|
||||
#
|
||||
##############################################
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
# Name and release number of this package
|
||||
PKG_NAME:=cpulimit-ng
|
||||
PKG_VERSION:=1.2
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
# This specifies the directory where we're going to build the program.
|
||||
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
|
||||
# directory in your OpenWrt SDK directory
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
# Specify package information for this program.
|
||||
# The variables defined here should be self explanatory.
|
||||
define Package/cpulimit-ng
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=CPU Usage Limiter for Linux
|
||||
description:=\
|
||||
cpulimit-ng is a simple program which attempts to \\\
|
||||
limit the cpu usage of a process (expressed in \\\
|
||||
percentage, not in cpu time).
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=CPU Usage Limiter for Linux
|
||||
endef
|
||||
|
||||
# using default Build/Prepare to enable patch (ElonH<elonhhuang@gmail.com>)
|
||||
define Pacakge/cpulimit-ng/description
|
||||
cpulimit-ng is a simple program which attempts to limit the cpu
|
||||
usage of a process (expressed in percentage, not in cpu time).
|
||||
endef
|
||||
|
||||
# We do not need to define Build/Configure or Build/Compile directives
|
||||
# The defaults are appropriate for compiling a simple program such as this one
|
||||
|
||||
# Specify where and how to install the program. Since we only have one file,
|
||||
# the cpulimit-ng executable, install it by copying it to the /bin directory on
|
||||
# the router. The $(1) variable represents the root directory on the router running
|
||||
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
|
||||
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
|
||||
# command to copy the binary file from its current location (in our case the build
|
||||
# directory) to the install directory.
|
||||
define Package/cpulimit-ng/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cpulimit-ng $(1)/bin/
|
||||
endef
|
||||
|
||||
# This line executes the necessary commands to compile our program.
|
||||
# The above define directives specify all the information needed, but this
|
||||
# line calls BuildPackage which in turn actually uses this information to
|
||||
# build a package.
|
||||
$(eval $(call BuildPackage,cpulimit-ng))
|
||||
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
based on cpulimit@sf svn version revision 41
|
||||
Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
|
||||
@ -1,32 +1,23 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=cpulimit
|
||||
PKG_VERSION:=cabeb9947c
|
||||
PKG_RELEASE:=1
|
||||
PKG_REV:=cabeb9947ccddd9a6e6ba14503e2a33063ac1b21
|
||||
PKG_VERSION:=0.2
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
#PKG_SOURCE_PROTO:=git
|
||||
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
#PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
#PKG_SOURCE_URL:=https://github.com/opsengine/cpulimit.git
|
||||
#PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/cpulimit
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=cpulimit
|
||||
URL:=https://github.com/opsengine/cpulimit.git
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Package/cpulimit/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cpulimit $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cpulimit $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
|
||||
|
||||
32
package/ntlf9t/dvb-firmware/Makefile
Normal file
32
package/ntlf9t/dvb-firmware/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright (C) 2017 McMCC
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dvb-firmware
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dvb-firmware
|
||||
SECTION:=firmware
|
||||
CATEGORY:=Firmware
|
||||
TITLE:=dvb-firmware megapack
|
||||
endef
|
||||
|
||||
define Package/dvb-firmware/description
|
||||
dvb-firmware is specialised software that is both specific to some hardware
|
||||
and also integral for its proper functioning.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/dvb-firmware/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware
|
||||
$(CP) $(CURDIR)/files/* $(1)/lib/firmware/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dvb-firmware))
|
||||
@ -1,40 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2017 McMCC
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=dvb-firmware
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dvb-firmware
|
||||
SECTION:=dvb-firmware
|
||||
CATEGORY:=Firmware
|
||||
TITLE:=dvb-firmware megapack
|
||||
endef
|
||||
|
||||
define Package/dvb-firmware/description
|
||||
dvb-firmware is specialised software that is both specific to some hardware
|
||||
and also integral for its proper functioning.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)/firmware
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/firmware
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/dvb-firmware/install
|
||||
$(INSTALL_DIR) $(1)/lib/firmware
|
||||
$(CP) $(PKG_BUILD_DIR)/firmware/* $(1)/lib/firmware
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dvb-firmware))
|
||||
@ -9,37 +9,33 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fcgiwrap
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_MAINTAINER:=Tobias Waldvogel <tobias.waldvogel@gmail.com>
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
define Package/fcgiwrap
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=FCGI wrapper for CGI
|
||||
DEPENDS:=+libpcre +spawn-fcgi +fcgi
|
||||
MAINTAINER:=Tobias Waldvogel <tobias.waldvogel@gmail.com>
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) \
|
||||
-I$(STAGING_DIR)/usr/include $(TARGET_CFLAGS) -Wall -Werror \
|
||||
-L$(STAGING_DIR)/usr/lib -lfcgi \
|
||||
-o$(PKG_BUILD_DIR)/$(PKG_NAME) $(PKG_BUILD_DIR)/$(PKG_NAME).c
|
||||
-o$(PKG_BUILD_DIR)/fcgiwrap $(PKG_BUILD_DIR)/fcgiwrap.c
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
define Package/fcgiwrap/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/fcgiwrap $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/fcgiwrap.init $(1)/etc/init.d/fcgiwrap
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,fcgiwrap))
|
||||
|
||||
@ -7,32 +7,32 @@
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME := libdvbcsa
|
||||
PKG_RELEASE := 1
|
||||
PKG_NAME:=libdvbcsa
|
||||
PKG_BASE_VERSION:=1.1.0
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO := git
|
||||
PKG_SOURCE_URL := https://github.com/glenvt18/libdvbcsa.git
|
||||
PKG_SOURCE_VERSION := 2a1e61e569a621c55c2426f235f42c2398b7f18f
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/glenvt18/libdvbcsa.git
|
||||
PKG_SOURCE_DATE:=2018-01-28
|
||||
PKG_SOURCE_VERSION:=2a1e61e569a621c55c2426f235f42c2398b7f18f
|
||||
PKG_MIRROR_HASH:=125c5d42fd1c73d3046ab9ee52d11d4c6495a2df45daa3eaf7bc5412dd91d586
|
||||
|
||||
PKG_VERSION := 1.1.0-$(shell printf '%.8s' $(PKG_SOURCE_VERSION))
|
||||
#PKG_SOURCE := $(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
#PKG_SOURCE_URL := http://download.videolan.org/pub/videolan/libdvbcsa/$(PKG_VERSION)/
|
||||
#PKG_HASH := 4db78af5cdb2641dfb1136fe3531960a477c9e3e3b6ba19a2754d046af3f456d
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION))
|
||||
|
||||
PKG_LICENSE := GPL-2.0
|
||||
PKG_LICENSE_FILE := COPYING
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILE:=COPYING
|
||||
PKG_MAINTAINER:=Tomasz Maciej Nowak <tomek_n@o2.pl>
|
||||
|
||||
PKG_MAINTAINER := Tomasz Maciej Nowak <tomek_n@o2.pl>
|
||||
|
||||
PKG_INSTALL := 1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/libdvbcsa
|
||||
SECTION := libs
|
||||
CATEGORY := Libraries
|
||||
TITLE := DVB Common Scrambling Algorithm library
|
||||
URL := https://www.videolan.org/developers/libdvbcsa.html
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=DVB Common Scrambling Algorithm library
|
||||
URL:=https://www.videolan.org/developers/libdvbcsa.html
|
||||
endef
|
||||
|
||||
define Package/libdvbcsa/description
|
||||
@ -46,7 +46,7 @@ define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr $(1)/
|
||||
$(CP) $(PKG_INSTALL_DIR)/* $(1)/
|
||||
endef
|
||||
|
||||
define Package/libdvbcsa/install
|
||||
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
@ -9,41 +10,35 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=minieap
|
||||
PKG_VERSION:=0.93
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/updateing/minieap.git
|
||||
PKG_SOURCE_VERSION:=9e10f320a9fce46c8f4286324a0fc70e572f61dc
|
||||
PKG_MIRROR_HASH:=41c976810c994d6125f6fe3cb1d978f7e257aa587ee32229364942a82621b273
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/updateing/minieap/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=41c976810c994d6125f6fe3cb1d978f7e257aa587ee32229364942a82621b273
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/minieap
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Extendable 802.1x client
|
||||
URL:=https://github.com/updateing/minieap
|
||||
SUBMENU:=Campus Network
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBNEMU:=Campus Network
|
||||
TITLE:=Extendable 802.1x client
|
||||
URL:=https://github.com/updateing/minieap
|
||||
endef
|
||||
|
||||
define Package/minieap/description
|
||||
Extendable 802.1x client with Ruijie v3 (v4) plugin.
|
||||
endef
|
||||
|
||||
define Package/minieap/conffiles
|
||||
/etc/minieap.conf
|
||||
Extendable 802.1x client with Ruijie v3 (v4) plugin.
|
||||
endef
|
||||
|
||||
define Package/minieap/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/minieap $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/local/sbin/minieap $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,minieap))
|
||||
|
||||
11
package/ntlf9t/minieap/patches/003-remove-systemctl.patch
Normal file
11
package/ntlf9t/minieap/patches/003-remove-systemctl.patch
Normal file
@ -0,0 +1,11 @@
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -87,7 +87,7 @@ install: minieap minieap.1.gz minieap.service
|
||||
install -m 644 minieap.1.gz $(DESTDIR)$(PREFIX)/share/man/man1/
|
||||
install -d $(DESTDIR)$(SYSTEMDDIR)/system/
|
||||
install -m 644 minieap.service $(DESTDIR)$(SYSTEMDDIR)/system/
|
||||
- -systemctl enable minieap
|
||||
+ # -systemctl enable minieap
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
@ -2,31 +2,32 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ngrokc
|
||||
PKG_VERSION:=1.54
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://github.com/dosgo/ngrok-c.git
|
||||
PKG_SOURCE_VERSION:=5ecd4e03d04ac538051fe8f1b0deaca500dc7185
|
||||
PKG_MIRROR_HASH:=6bb27003b9357e9edd07b3b869e150ad506b253f3469fbbbae1fcece630afeb2
|
||||
PKG_SOURCE_DATE:=2019-11-02
|
||||
PKG_SOURCE_VERSION:=6388b9d8e4d5fef018ee64dfd55795f10cc6aaad
|
||||
PKG_MIRROR_HASH:=a0f22073807e0ae7869cecce398e848800e5961e00d76a6185f0c1004609f093
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ngrokc
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=Secure tunnels to localhost(C++ port)
|
||||
URL:=https://github.com/dosgo/ngrok-c
|
||||
DEPENDS:=+libc +libpthread +libopenssl +libstdcpp
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=Secure tunnels to localhost (C++ port)
|
||||
URL:=https://github.com/dosgo/ngrok-c
|
||||
DEPENDS:=+libc +libpthread +libopenssl +libstdcpp
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default,)
|
||||
$(call Build/Prepare/Default)
|
||||
$(CP) $(PKG_BUILD_DIR)/Makefile.openssl $(PKG_BUILD_DIR)/Makefile
|
||||
endef
|
||||
|
||||
|
||||
@ -1,48 +1,40 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=njit8021xclient
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_BASE_VERSION:=2.0
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/bitdust/njit8021xclient.git
|
||||
PKG_SOURCE_DATE:=2018-11-24
|
||||
PKG_SOURCE_VERSION:=dd28c17f24275bbbf4c44504b832c0f1e6b9ae40
|
||||
PKG_MIRROR_HASH:=689c01fe559a1ad00446bdb92890ddfcfbe0f53e5afd9ae54d5649e7a43ff961
|
||||
PKG_MIRROR_HASH:=66e4f20ceeceaed457657b60ec0b390aab0d7ff380b0abe749738b8f4aa23556
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION))
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/njit8021xclient
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=NJIT 802.1X client program
|
||||
DEPENDS:=+libopenssl +libpcap
|
||||
SUBMENU:=Campus Network
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Campus Network
|
||||
TITLE:=NJIT 802.1X client program
|
||||
DEPENDS:=+libopenssl +libpcap
|
||||
endef
|
||||
|
||||
define Package/njit8021xclient/description
|
||||
802.1X client from Nanjing Institude of Technology,
|
||||
compatable with H3C iNode 802.1X client. Support
|
||||
H3C/iNode's private authentication protocol V7.10.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/ \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CFLAGS="$(TARGET_CFLAGS) -static" \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS)" \
|
||||
LIBS="$(STAGING_DIR)/usr/lib/libpcap.a"
|
||||
802.1X client from Nanjing Institude of Technology, compatable with
|
||||
H3C iNode 802.1X client. Support H3C/iNode's private authentication
|
||||
protocol V7.10.
|
||||
endef
|
||||
|
||||
define Package/njit8021xclient/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/client $(1)/usr/sbin/njit-client
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/njit-client $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,njit8021xclient))
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2014-2018 OpenWrt-dist
|
||||
# Copyright (C) 2014-2018 Jian Chang <aa65535@live.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=openwrt_chinadns
|
||||
PKG_VERSION:=1.3.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/aa65535/ChinaDNS.git
|
||||
PKG_MIRROR_HASH:=3d7063552dc5755163be52de7311fcbed87f67622bbf4c1b0dc748431b57091b
|
||||
PKG_SOURCE_VERSION:=00616680114011553881760e843b77a3519e8fbf
|
||||
PKG_SOURCE_SUBDIR:=ChinaDNS-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=ChinaDNS-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Jian Chang <aa65535@live.com>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/ChinaDNS-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Protect yourself against DNS poisoning in China.
|
||||
URL:=https://github.com/shadowsocks/ChinaDNS
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Protect yourself against DNS poisoning in China.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/chinadns $(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@ -1,62 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pdnsd
|
||||
PKG_VERSION:=1.2.9a-par
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/shadowsocksrr/pdnsd.git
|
||||
PKG_MIRROR_HASH:=277bdc34c27377b7626d83a6625b6f07f0e7268d5e8d926152ffe9e5022cc338
|
||||
PKG_SOURCE_VERSION:=a8e46ccba7b0fa2230d6c42ab6dcd92926f6c21d
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_USE_MIPS16:=0
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/pdnsd-full
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libpthread
|
||||
TITLE:=Proxy DNS Server
|
||||
endef
|
||||
|
||||
define Package/pdnsd-full/conffiles
|
||||
/etc/pdnsd.conf
|
||||
endef
|
||||
|
||||
define Package/pdnsd-full/description
|
||||
pdnsd, is an IPv6 capable proxy DNS server with permanent caching (the cache
|
||||
contents are written to hard disk on exit) that is designed to cope with
|
||||
unreachable or down DNS servers (for example in dial-in networking).
|
||||
|
||||
pdnsd can be used with applications that do dns lookups, eg on startup, and
|
||||
can't be configured to change that behaviour, to prevent the often
|
||||
minute-long hangs (or even crashes) that result from stalled dns queries.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += --enable-ipv6 --enable-ipv6-startup --enable-tcp-subseq --with-cachedir=/var/pdnsd --with-query-method=tcpudp
|
||||
|
||||
TARGET_CFLAGS += -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
# Use Link time optimization
|
||||
TARGET_CFLAGS += -flto
|
||||
TARGET_LDFLAGS += -Wl,-flto
|
||||
|
||||
define Package/pdnsd-full/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/pdnsd $(1)/usr/sbin/pdnsd-full
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/pdnsd-ctl/pdnsd-ctl $(1)/usr/bin/pdnsd-ctl-full
|
||||
#$(INSTALL_DIR) $(1)/etc
|
||||
#$(INSTALL_CONF) ./files/pdnsd.conf $(1)/etc/pdnsd.conf
|
||||
# $(INSTALL_CONF) $(PKG_BUILD_DIR)/doc/pdnsd.conf $(1)/etc/)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,pdnsd-full))
|
||||
@ -1,33 +0,0 @@
|
||||
global {
|
||||
cache_dir = "/var/pdnsd";
|
||||
perm_cache = 1024;
|
||||
run_as = "nobody";
|
||||
server_ip = 127.0.0.1;
|
||||
server_port = 5300;
|
||||
status_ctl = on;
|
||||
# paranoid = on;
|
||||
query_method = tcp_udp;
|
||||
min_ttl = 15m;
|
||||
max_ttl = 1w;
|
||||
timeout = 10;
|
||||
neg_domain_pol = on;
|
||||
udpbufsize = 1024;
|
||||
}
|
||||
|
||||
server {
|
||||
label = "opendns";
|
||||
ip = "208.67.222.222", "208.67.220.220";
|
||||
port = 5353;
|
||||
timeout = 4;
|
||||
uptest = ping;
|
||||
ping_timeout = 100;
|
||||
interval = 15m;
|
||||
purge_cache = off;
|
||||
}
|
||||
|
||||
source {
|
||||
ttl = 86400;
|
||||
owner = localhost;
|
||||
serve_aliases = on;
|
||||
file = "/etc/hosts";
|
||||
}
|
||||
@ -6,20 +6,20 @@
|
||||
#
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME := oscam
|
||||
PKG_REV := 33e2d6
|
||||
PKG_VERSION := r11518-$(PKG_REV)
|
||||
PKG_RELEASE := 1
|
||||
PKG_NAME:=oscam
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:= git
|
||||
PKG_SOURCE_VERSION := $(PKG_REV)
|
||||
PKG_SOURCE_URL := https://github.com/nx111/oscam.git
|
||||
PKG_MIRROR_HASH := 6873d24637f14ec695e32a8a91f17bd8ef38d615a55fb76e6440f6a37da906e3
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/nx111/oscam.git
|
||||
PKG_SOURCE_DATE:=2020-12-12
|
||||
PKG_SOURCE_VERSION:=aafda4bca3c347698ef1dc32f7ebeff76378d55a
|
||||
PKG_MIRROR_HASH:=d2cd4508ef80a3cbd8ef950e5446f2f754b339f179c4f774ef8660b39fd5c4c1
|
||||
|
||||
PKG_LICENSE := GPL-3.0
|
||||
PKG_LICENSE_FILE := COPYING
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILE:=COPYING
|
||||
PKG_MAINTAINER:=Tomasz Maciej Nowak <tomek_n@o2.pl>
|
||||
|
||||
PKG_MAINTAINER := Tomasz Maciej Nowak <tomek_n@o2.pl>
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -28,23 +28,23 @@ define Package/oscam/config
|
||||
endef
|
||||
|
||||
define Package/oscam
|
||||
SECTION := net
|
||||
CATEGORY := Network
|
||||
TITLE := Open Source Conditional Access Modul
|
||||
URL := http://www.streamboard.tv/oscam
|
||||
DEPENDS := +OSCAM_USE_LIBCRYPTO:libopenssl +OSCAM_USE_LIBUSB:libusb-1.0 +OSCAM_USE_PCSC:pcscd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Open Source Conditional Access Modul
|
||||
URL:=http://www.streamboard.tv/oscam
|
||||
DEPENDS:=+OSCAM_USE_LIBCRYPTO:libopenssl +OSCAM_USE_LIBUSB:libusb-1.0 +OSCAM_USE_PCSC:pcscd
|
||||
endef
|
||||
|
||||
define Package/list-smargo
|
||||
SECTION := net
|
||||
CATEGORY := Network
|
||||
TITLE := List Smargo readers
|
||||
URL := http://www.streamboard.tv/oscam
|
||||
DEPENDS := oscam @OSCAM_CARDREADER_SMARGO
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=List Smargo readers
|
||||
URL:=http://www.streamboard.tv/oscam
|
||||
DEPENDS:=oscam @OSCAM_CARDREADER_SMARGO
|
||||
endef
|
||||
|
||||
CONFIGURE_CMD = ./config.sh
|
||||
CONFIGURE_ARGS = \
|
||||
CONFIGURE_CMD:=./config.sh
|
||||
CONFIGURE_ARGS+= \
|
||||
--restore \
|
||||
$(if $(CONFIG_OSCAM_WEBIF),--enable,--disable) WEBIF \
|
||||
$(if $(CONFIG_OSCAM_WEBIF_LIVELOG),--enable,--disable) WEBIF_LIVELOG \
|
||||
@ -133,7 +133,7 @@ define Package/oscam/install
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/Distribution/oscam $(1)/usr/bin/oscam
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/oscam
|
||||
# $(CP) $(PKG_BUILD_DIR)/Distribution/doc/example/* $(1)/etc/oscam/
|
||||
# $(CP) $(PKG_BUILD_DIR)/Distribution/doc/example/* $(1)/etc/oscam/
|
||||
$(INSTALL_CONF) ./files/oscam.conf $(1)/etc/oscam/oscam.conf
|
||||
$(INSTALL_CONF) ./files/oscam.user $(1)/etc/oscam/oscam.user
|
||||
$(INSTALL_CONF) ./files/oscam.dvbapi $(1)/etc/oscam/oscam.dvbapi
|
||||
|
||||
@ -7,23 +7,30 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pcap-dnsproxy
|
||||
PKG_VERSION:=0.4.9.13
|
||||
PKG_RELEASE:=bc9f540
|
||||
PKG_BASE_VERSION:=0.4.9.13
|
||||
PKG_RELEASE:=$(AUTORELESE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/1715173329/Pcap_DNSProxy.git
|
||||
PKG_MIRROR_HASH:=74d86515f17a329fe586fc9acb0c0ff3494fd7f39e42ed50f442d247e3205556
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_DATE:=2019-05-05
|
||||
PKG_SOURCE_VERSION:=bc9f540d9febc5f61d24d583dbdbcc858dd817e3
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
CMAKE_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_MIRROR_HASH:=416cea47ef5662c32111c56eeaaaaec4b338e6eddfe98fca0a0d854e00653dc3
|
||||
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION))
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_MAINTAINER:=Chengr28 <chengr28@gmail.com>
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_PCAP_DNSPROXY_LIBSODIUM \
|
||||
CONFIG_PCAP_DNSPROXY_LIBPCAP \
|
||||
CONFIG_PCAP_DNSPROXY_TLS \
|
||||
CONFIG_PCAP_DNSPROXY_LISTENPORT
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
@ -39,15 +46,12 @@ TARGET_CXXFLAGS += -std=c++14
|
||||
|
||||
CMAKE_OPTIONS += \
|
||||
-DPLATFORM_OPENWRT=ON \
|
||||
-DENABLE_LIBSODIUM=$(if $(CONFIG_PACKAGE_pcap-dnsproxy_libsodium),ON,OFF) \
|
||||
-DENABLE_PCAP=$(if $(CONFIG_PACKAGE_pcap-dnsproxy_libpcap),ON,OFF) \
|
||||
-DENABLE_TLS=$(if $(CONFIG_PACKAGE_pcap-dnsproxy_tls),ON,OFF)
|
||||
-DENABLE_LIBSODIUM=$(if $(CONFIG_PCAP_DNSPROXY_LIBSODIUM),ON,OFF) \
|
||||
-DENABLE_PCAP=$(if $(CONFIG_PCAP_DNSPROXY_LIBPCAP),ON,OFF) \
|
||||
-DENABLE_TLS=$(if $(CONFIG_PCAP_DNSPROXY_TLS),ON,OFF)
|
||||
|
||||
# Port 53 leads to dnsmasq startup failure.
|
||||
define Package/pcap-dnsproxy/config
|
||||
if PACKAGE_pcap-dnsproxy
|
||||
|
||||
config PACKAGE_pcap-dnsproxy_libpcap
|
||||
config PCAP_DNSPROXY_LIBPCAP
|
||||
bool "Build with libpcap support.(Strongly recommended)"
|
||||
default y
|
||||
help
|
||||
@ -55,7 +59,8 @@ if PACKAGE_pcap-dnsproxy
|
||||
of it to detect poisoned DNS reply.
|
||||
|
||||
We strongly recommend to keep it as-is.
|
||||
config PACKAGE_pcap-dnsproxy_libsodium
|
||||
|
||||
config PCAP_DNSPROXY_LIBSODIUM
|
||||
bool "Build with libsodium support.(Recommended)"
|
||||
default y
|
||||
help
|
||||
@ -63,11 +68,13 @@ if PACKAGE_pcap-dnsproxy
|
||||
|
||||
We recommend to keep it as-is unless you do NOT
|
||||
need this protocol anymore.
|
||||
config PACKAGE_pcap-dnsproxy_tls
|
||||
|
||||
config PCAP_DNSPROXY_TLS
|
||||
bool "Build with TLS support.(Recommended)"
|
||||
default y
|
||||
help
|
||||
We recommend to keep it as-is.
|
||||
|
||||
config PCAP_DNSPROXY_LISTENPORT
|
||||
int "Listen Port, should NOT be 53"
|
||||
default 1053
|
||||
@ -75,47 +82,19 @@ if PACKAGE_pcap-dnsproxy
|
||||
You can customize the listen port of Pcap_DNSProxy.
|
||||
Note that you should NOT set the value to 53, which
|
||||
conflicts with DNSMasq in OpenWrt.
|
||||
config PACKAGE_pcap-dnsproxy_advancedoptions
|
||||
bool "Compile with advanced options. (for expert only)"
|
||||
default n
|
||||
help
|
||||
Enable this option to use link-time optimization and
|
||||
other GCC compile flags to reduce binary size.
|
||||
|
||||
Please refer to Makefile for details.
|
||||
|
||||
Unless you know what you are doing, you
|
||||
should probably say N here.
|
||||
endif
|
||||
endef
|
||||
|
||||
# Note: GCC 4.6 and 4.8 dont have complete C++11 support
|
||||
# Please use GCC 4.9 or higher to compile
|
||||
# uclibcxx is uClibc++, which stands for C++ library for embedded systems.
|
||||
# libstdcpp is shipped by GCC project, which usually takes more space than uClibc++.
|
||||
# but it has more useful features we need, i.e. full regular expression support.
|
||||
define Package/pcap-dnsproxy
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=A local DNS server based on LibPcap
|
||||
URL:=https://github.com/chengr28/Pcap_DNSProxy
|
||||
DEPENDS:=+libpthread +libstdcpp +libevent2-core \
|
||||
+PACKAGE_pcap-dnsproxy_libpcap:libpcap \
|
||||
+PACKAGE_pcap-dnsproxy_libsodium:libsodium \
|
||||
+PACKAGE_pcap-dnsproxy_tls:libopenssl \
|
||||
@GCC_VERSION_4_6:BROKEN
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=A local DNS server based on LibPcap
|
||||
URL:=https://github.com/chengr28/Pcap_DNSProxy
|
||||
DEPENDS:=+libpthread +libstdcpp +libevent2-core \
|
||||
+PCAP_DNSPROXY_LIBPCAP:libpcap \
|
||||
+PCAP_DNSPROXY_LIBSODIUM:libsodium \
|
||||
+PCAP_DNSPROXY_TLS:libopenssl
|
||||
endef
|
||||
|
||||
# Some advanced compile flags for expert
|
||||
ifneq ($(CONFIG_PACKAGE_pcap-dnsproxy_advancedoptions),)
|
||||
# Try to reduce binary size
|
||||
TARGET_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
# Use Link time optimization
|
||||
TARGET_CXXFLAGS += -flto
|
||||
TARGET_LDFLAGS += -flto
|
||||
endif
|
||||
|
||||
define Package/pcap-dnsproxy/conffiles
|
||||
/etc/pcap-dnsproxy/Config.conf
|
||||
/etc/pcap-dnsproxy/Hosts.conf
|
||||
@ -134,7 +113,6 @@ fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
# Stop and disable service(removing rc.d symlink) before removing
|
||||
define Package/pcap-dnsproxy/prerm
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
@ -156,11 +134,11 @@ define Package/pcap-dnsproxy/install
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_BIN) ./files/pcap-dnsproxy.hotplug $(1)/etc/hotplug.d/iface/99-pcap-dnsproxy
|
||||
$(INSTALL_DIR) $(1)/etc/pcap-dnsproxy
|
||||
$(SED) 's,^\xEF\xBB\xBF,,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/*
|
||||
$(SED) 's,\x0D,,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/*
|
||||
$(SED) 's,Listen Port = 53,Listen Port = $(CONFIG_PCAP_DNSPROXY_LISTENPORT),g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(SED) 's,Log Maximum Size = 8MB,Log Maximum Size = 50KB,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(SED) 's,Operation Mode = Private,Operation Mode = Server,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(SED) 's,^\xEF\xBB\xBF,,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/*
|
||||
$(SED) 's,\x0D,,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/*
|
||||
$(SED) 's,Listen Port = 53,Listen Port = $(CONFIG_PCAP_DNSPROXY_LISTENPORT),g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(SED) 's,Log Maximum Size = 8MB,Log Maximum Size = 50KB,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(SED) 's,Operation Mode = Private,Operation Mode = Server,g' $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Config.ini $(1)/etc/pcap-dnsproxy/Config.conf
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/Hosts.ini $(1)/etc/pcap-dnsproxy/Hosts.conf
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/Source/Auxiliary/ExampleConfig/IPFilter.ini $(1)/etc/pcap-dnsproxy/IPFilter.conf
|
||||
@ -168,5 +146,4 @@ define Package/pcap-dnsproxy/install
|
||||
$(INSTALL_CONF) ./files/configs/WhiteList.txt $(1)/etc/pcap-dnsproxy/WhiteList.txt
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,pcap-dnsproxy))
|
||||
@ -8,22 +8,23 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=scutclient
|
||||
PKG_VERSION:=3.1.2
|
||||
PKG_RELEASE:=1
|
||||
PKG_BASE_VERSION:=3.1.2
|
||||
PKG_RELEASE:=$(AUTORELESE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/scutclient/scutclient.git
|
||||
PKG_SOURCE_DATE:=2020-11-29
|
||||
PKG_SOURCE_VERSION:=36128216c63f8954371e64d78ff30bca5e73a882
|
||||
PKG_MIRROR_HASH:=ffce8508a7d083150d6484b7272ea832432dcfde9ad8773c2a6d1785bef41191
|
||||
PKG_MIRROR_HASH:=16be6312e7ca2e1b0201c2d2f7e01dbb6173fb9b13c93707ff272f992d4b3bff
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
PKG_VERSION:=$(PKG_BASE_VERSION)-$(PKG_SOURCE_DATE)-$(call version_abbrev,$(PKG_SOURCE_VERSION))
|
||||
|
||||
PKG_MAINTAINER:=Scutclient Project
|
||||
|
||||
PKG_LICENSE:=AGPL-3.0
|
||||
PKG_LICENSE_FILE:=COPYING
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
@ -31,9 +32,9 @@ include $(INCLUDE_DIR)/cmake.mk
|
||||
define Package/scutclient
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Campus Network
|
||||
TITLE:=SCUT Dr.com client
|
||||
URL:=https://github.com/scutclient/scutclient
|
||||
SUBMENU:=Campus Network
|
||||
endef
|
||||
|
||||
define Package/scutclient/description
|
||||
@ -52,7 +53,7 @@ define Package/scutclient/install
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/files/scutclient.hotplug $(1)/etc/hotplug.d/iface/99-scutclient
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scutclient $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/scutclient $(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,scutclient))
|
||||
|
||||
@ -1,31 +1,27 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sysuh3c
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELESE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/haswelliris/h3c.git
|
||||
PKG_MIRROR_HASH:=3175d4c9d6a4b39a5e4b2ef347e938c092305854057196961f70935723532170
|
||||
PKG_SOURCE_VERSION:=fdf66c3
|
||||
PKG_SOURCE_DATE:=2019-03-01
|
||||
PKG_SOURCE_VERSION:=8a3e0b5a9a5d989e7d8b2105d09a394c3663e016
|
||||
PKG_MIRROR_HASH:=693fd9f81242edb3459a1298f4c850984e59fb44ef6fb4a40fdfcdd3c14acfdb
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=H3C client
|
||||
SUBMENU:=Campus Network
|
||||
define Package/sysuh3c
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Campus Network
|
||||
TITLE:=H3C client
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
$(call Build/Configure/Default)
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
define Package/sysuh3c/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/h3c $(1)/usr/sbin/sysuh3c
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
@ -34,4 +30,4 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_BIN) ./files/sysuh3c.init $(1)/etc/init.d/sysuh3c
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
$(eval $(call BuildPackage,sysuh3c))
|
||||
|
||||
@ -9,35 +9,30 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=udp2raw-tunnel
|
||||
PKG_VERSION:=20200818.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/wangyu-/udp2raw-tunnel.git
|
||||
PKG_MIRROR_HASH:=6b7c07f6277729ba8b3b287316b5b7a80c5b1e47258ecc8b1c8618be3aa73888
|
||||
PKG_SOURCE_VERSION:=cc6ea766c495cf4c69d1c7485728ba022b0f19de
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/wangyu-/udp2raw-tunnel/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=712b0cb819555cb374206e95005b0ca6b4af86c74d572e0570630f67dfeea313
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Yu Wang
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/udp2raw-tunnel
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic
|
||||
URL:=https://github.com/wangyu-/udp2raw-tunnel
|
||||
DEPENDS:= +libstdcpp +libpthread +librt
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic
|
||||
URL:=https://github.com/wangyu-/udp2raw-tunnel
|
||||
DEPENDS:=+libstdcpp +libpthread +librt
|
||||
endef
|
||||
|
||||
define Package/udp2raw-tunnel/description
|
||||
udp2raw-tunnel is a tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic by using Raw Socket.
|
||||
udp2raw-tunnel is a tunnel which turns UDP Traffic into Encrypted FakeTCP/UDP/ICMP Traffic by using Raw Socket.
|
||||
endef
|
||||
|
||||
MAKE_FLAGS += cross
|
||||
Loading…
Reference in New Issue
Block a user