Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/protocool/speedlimit
Browse files Browse the repository at this point in the history
Conflicts:
	English.lproj/SpeedLimitPref.xib
  • Loading branch information
Jesse Armand committed Oct 31, 2009
2 parents b0269c0 + 37e8eb6 commit 2c6cca5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 2,124 deletions.
Binary file removed English.lproj/InfoPlist.strings
Binary file not shown.
2,106 changes: 0 additions & 2,106 deletions English.lproj/SpeedLimitPref.xib

This file was deleted.

2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
Expand Down
36 changes: 22 additions & 14 deletions SpeedLimit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
557302F20E68FAE200E88032 /* SpeedLimit.png in Resources */ = {isa = PBXBuildFile; fileRef = 557302F10E68FAE200E88032 /* SpeedLimit.png */; };
557302FB0E6903EC00E88032 /* SpeedLimiter in Resources */ = {isa = PBXBuildFile; fileRef = 557302F90E6903EC00E88032 /* SpeedLimiter */; };
557303000E69042800E88032 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 557302FF0E69042800E88032 /* Security.framework */; };
88CC2648109BE8CF001F20AC /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 88CC2644109BE8CF001F20AC /* InfoPlist.strings */; };
88CC2649109BE8CF001F20AC /* SpeedLimitPref.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88CC2646109BE8CF001F20AC /* SpeedLimitPref.xib */; };
88F7EB78106C07D700745902 /* SecurityInterface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88F7EB77106C07D700745902 /* SecurityInterface.framework */; };
8D202CEA0486D31800D8A456 /* SpeedLimit_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA20370C41700C91783 /* SpeedLimit_Prefix.pch */; };
8D202CEB0486D31800D8A456 /* SpeedLimitPref.h in Headers */ = {isa = PBXBuildFile; fileRef = F506C03C013D9D7901CA16C8 /* SpeedLimitPref.h */; };
8D202CED0486D31800D8A456 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D202CEE0486D31800D8A456 /* SpeedLimitPref.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F506C040013D9D8001CA16C8 /* SpeedLimitPref.tiff */; };
8D202CEF0486D31800D8A456 /* SpeedLimitPref.xib in Resources */ = {isa = PBXBuildFile; fileRef = F506C042013D9D8C01CA16C8 /* SpeedLimitPref.xib */; };
8D202CF10486D31800D8A456 /* SpeedLimitPref.m in Sources */ = {isa = PBXBuildFile; fileRef = F506C03D013D9D7901CA16C8 /* SpeedLimitPref.m */; };
8D202CF30486D31800D8A456 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
8D202CF40486D31800D8A456 /* PreferencePanes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F506C035013D953901CA16C8 /* PreferencePanes.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
32DBCFA20370C41700C91783 /* SpeedLimit_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeedLimit_Prefix.pch; sourceTree = "<group>"; };
Expand All @@ -34,14 +33,15 @@
557302F10E68FAE200E88032 /* SpeedLimit.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SpeedLimit.png; sourceTree = "<group>"; };
557302F90E6903EC00E88032 /* SpeedLimiter */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = SpeedLimiter; sourceTree = "<group>"; };
557302FF0E69042800E88032 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
88CC2645109BE8CF001F20AC /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
88CC2647109BE8CF001F20AC /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/SpeedLimitPref.xib; sourceTree = "<group>"; };
88F7EB77106C07D700745902 /* SecurityInterface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SecurityInterface.framework; path = /System/Library/Frameworks/SecurityInterface.framework; sourceTree = "<absolute>"; };
8D202CF70486D31800D8A456 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D202CF80486D31800D8A456 /* SpeedLimit.prefPane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SpeedLimit.prefPane; sourceTree = BUILT_PRODUCTS_DIR; };
F506C035013D953901CA16C8 /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = /System/Library/Frameworks/PreferencePanes.framework; sourceTree = "<absolute>"; };
F506C03C013D9D7901CA16C8 /* SpeedLimitPref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeedLimitPref.h; sourceTree = "<group>"; };
F506C03D013D9D7901CA16C8 /* SpeedLimitPref.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SpeedLimitPref.m; sourceTree = "<group>"; };
F506C040013D9D8001CA16C8 /* SpeedLimitPref.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = SpeedLimitPref.tiff; sourceTree = "<group>"; };
F506C043013D9D8C01CA16C8 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/SpeedLimitPref.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -83,12 +83,12 @@
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
88CC2644109BE8CF001F20AC /* InfoPlist.strings */,
88CC2646109BE8CF001F20AC /* SpeedLimitPref.xib */,
557302F90E6903EC00E88032 /* SpeedLimiter */,
557302F10E68FAE200E88032 /* SpeedLimit.png */,
8D202CF70486D31800D8A456 /* Info.plist */,
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
F506C040013D9D8001CA16C8 /* SpeedLimitPref.tiff */,
F506C042013D9D8C01CA16C8 /* SpeedLimitPref.xib */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -183,7 +183,15 @@
isa = PBXProject;
buildConfigurationList = 1DBD214C08BA80EA00186707 /* Build configuration list for PBXProject "SpeedLimit" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = en;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
en,
);
mainGroup = 089C166AFE841209C02AAC07 /* SpeedLimit */;
projectDirPath = "";
projectRoot = "";
Expand All @@ -198,11 +206,11 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D202CED0486D31800D8A456 /* InfoPlist.strings in Resources */,
8D202CEE0486D31800D8A456 /* SpeedLimitPref.tiff in Resources */,
8D202CEF0486D31800D8A456 /* SpeedLimitPref.xib in Resources */,
557302F20E68FAE200E88032 /* SpeedLimit.png in Resources */,
557302FB0E6903EC00E88032 /* SpeedLimiter in Resources */,
88CC2648109BE8CF001F20AC /* InfoPlist.strings in Resources */,
88CC2649109BE8CF001F20AC /* SpeedLimitPref.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -231,21 +239,21 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
88CC2644109BE8CF001F20AC /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C167EFE841241C02AAC07 /* English */,
88CC2645109BE8CF001F20AC /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
sourceTree = SOURCE_ROOT;
};
F506C042013D9D8C01CA16C8 /* SpeedLimitPref.xib */ = {
88CC2646109BE8CF001F20AC /* SpeedLimitPref.xib */ = {
isa = PBXVariantGroup;
children = (
F506C043013D9D8C01CA16C8 /* English */,
88CC2647109BE8CF001F20AC /* en */,
);
name = SpeedLimitPref.xib;
sourceTree = "<group>";
sourceTree = SOURCE_ROOT;
};
/* End PBXVariantGroup section */

Expand Down
4 changes: 4 additions & 0 deletions SpeedLimitPref.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
Speed *speed;
NSArray *rules;
BOOL slow;
double packetLossRatio;
BOOL packetLossErrorSuppress;

NSArrayController *speedsController;
NSArrayController *portsController;
Expand All @@ -39,6 +41,8 @@
@property (readwrite, retain) Speed *speed;
@property (readwrite, retain) NSArray *rules;
@property (readwrite, assign) BOOL slow;
@property (readwrite, assign) double packetLossRatio;
@property (readwrite, assign) BOOL packetLossErrorSuppress;

@property (readwrite, retain) IBOutlet NSArrayController *speedsController;
@property (readwrite, retain) IBOutlet NSArrayController *portsController;
Expand Down
6 changes: 6 additions & 0 deletions SpeedLimitPref.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ @implementation SpeedLimitPref
@synthesize speed;
@synthesize rules;
@synthesize slow;
@synthesize packetLossRatio;
@synthesize packetLossErrorSuppress;
@synthesize speedLimitLabel;
@synthesize portsView;
@synthesize hostsTextField;
Expand Down Expand Up @@ -269,9 +271,13 @@ -(IBAction)toggle:(id)sender {
NSString *finalSpeed = [NSString stringWithFormat:@"%ld", speed.speed];
NSString *finalDelay = (self.delay == nil || [self.delay length] == 0) ? 0 : self.delay;
NSString *finalHosts = (self.hosts == nil) ? @"" : self.hosts;
NSString *finalPacketLossRatio = [[NSNumber numberWithDouble:self.packetLossRatio] stringValue];
NSString *finalPacketLossErrorSuppress = (self.packetLossErrorSuppress) ? @"yes" : @"no";
NSMutableArray *arguments = [NSMutableArray array];
[arguments addObject:finalSpeed];
[arguments addObject:finalDelay];
[arguments addObject:finalPacketLossRatio];
[arguments addObject:finalPacketLossErrorSuppress];
[arguments addObject:finalHosts];
[arguments addObjectsFromArray:ports];
self.rules = [self rulesForCommand:@"start" withArguments:arguments];
Expand Down
18 changes: 15 additions & 3 deletions SpeedLimiter
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@ shift

if [[ "$ACTION" == "start" ]]; then
if [[ $# < 4 ]]; then
echo "Usage: $0 start [kps] [delay] [comma-separated hosts|\"any\"] [port1] <port2> .. <portn>"
echo "Usage: $0 start [kps] [delay] [plr] [plr-suppress] [comma-separated hosts|\"any\"] [port1] <port2> .. <portn>"
fi
SPEED="$1Kbit/s"
shift

DELAY="$1ms"
shift

PLR="$1"
shift

PLR_SUPPRESS="$1"
shift

if [[ "$PLR_SUPPRESS" == "yes" ]]; then
PLR_SUPPRESS="noerror"
else
PLR_SUPPRESS=""
fi

HOSTS="${1//,/ }"
if [[ "$HOSTS" == "" ]]; then
HOSTS="any"
Expand All @@ -27,10 +39,10 @@ if [[ "$ACTION" == "start" ]]; then
HOST=${HOST// /}
/sbin/ipfw add pipe $PIPE ip from $HOST $PORT to me
#/sbin/ipfw add pipe $PIPE ip from any $PORT to $HOST out
/sbin/ipfw pipe $((PIPE ++)) config bw $SPEED queue 64Kbytes delay $DELAY
/sbin/ipfw pipe $((PIPE ++)) config $PLR_SUPPRESS bw $SPEED queue 64Kbytes delay $DELAY plr $PLR
/sbin/ipfw add pipe $PIPE ip from me $PORT to $HOST
#/sbin/ipfw add pipe $PIPE ip from any $PORT to $HOST in
/sbin/ipfw pipe $((PIPE ++)) config bw $SPEED queue 64Kbytes delay $DELAY
/sbin/ipfw pipe $((PIPE ++)) config $PLR_SUPPRESS bw $SPEED queue 64Kbytes delay $DELAY plr $PLR
done
done
elif [[ "$ACTION" == "stop" ]]; then
Expand Down

0 comments on commit 2c6cca5

Please sign in to comment.