Skip to content

Commit

Permalink
Merge pull request #6 from mulot/developpement
Browse files Browse the repository at this point in the history
Developpement
  • Loading branch information
mulot authored Jul 12, 2021
2 parents d75a6ea + 295e241 commit 5cc46aa
Show file tree
Hide file tree
Showing 7 changed files with 836 additions and 139 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ iOSInjectionProject/

__MACOSX
.DS_Store
.zhistory

516 changes: 459 additions & 57 deletions Base.lproj/MainMenu.xib

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions IPSubnetcalc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,19 @@ class IPSubnetCalc: NSObject {
return (bitMap)
}

// return maskbits and number of max hosts for this mask
static func fittingSubnet(hosts: UInt) -> (Int, UInt) {
var maxHosts: UInt

for index in 1...31 {
maxHosts = UInt(truncating: NSDecimalNumber(decimal: pow(2, index))) - 2
if (hosts <= maxHosts) {
return (32 - index, maxHosts)
}
}
return (0, 0)
}

func displayIPInfo() {
print("IP Host : " + self.ipv4Address)
print("Mask bits : \(self.maskBits)")
Expand Down Expand Up @@ -548,39 +561,39 @@ class IPSubnetCalc: NSObject {

ip4Hex = ipAddress.components(separatedBy: ":")
if (ip4Hex == nil) {
print("\(ipAddress) invalid")
//print("\(ipAddress) invalid")
return false
}
if (ip4Hex!.count != 8) {
print("no 8 hex")
//print("no 8 hex")
if (ipAddress.contains("::"))
{
if (ipAddress.components(separatedBy: "::").count > 2) {
print("too many '::'")
//print("too many '::'")
return false
}
}
else {
print("IPv6 \(ipAddress) bad format")
//print("IPv6 \(ipAddress) bad format")
return false
}
}
for index in 0...(ip4Hex!.count - 1) {
//print("Index : \(index) IPHex : \(ip4Hex[index]) Dec : \(String(UInt16(ip4Hex[index], radix: 16)!, radix: 16))")
if (ip4Hex![index].count > 4 && ip4Hex![index].count != 0) {
print("\(ip4Hex![index]) too large")
//print("\(ip4Hex![index]) too large")
return false
}
hex = UInt16(ip4Hex![index], radix: 16)
if hex != nil {
if (hex! < 0 || hex! > 0xFFFF) {
print("\(hex!) is invalid")
//print("\(hex!) is invalid")
return false
}
}
else {
if (ip4Hex![index] != "") {
print("\(ip4Hex![index]) not an integer")
//print("\(ip4Hex![index]) not an integer")
return false
}
}
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# SubnetCalc
Subnet Calculator for MacOS

What's New in version 2.0:
- IPv6 support!
- Address Class D (Multicast) and Class E (Reserved) support
- 31 and 32 mask bits support
- New Tab presentation
- Recoded in Swift
- Add alerts for bad IP or mask format
- Fix bugs
What's New in version 2.1:
- FLSM (Fixed Length Subnet Mask) support
- VLSM (Variable Length Subnet Mask) support
- Export FSLM result in a CSV file
- Export VSLM result in a CSV file


For more information: http://subnetcalc.mulot.org
Expand Down
6 changes: 3 additions & 3 deletions SubnetCalc-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.1</string>
<key>CFBundleSignature</key>
<string>JMUL</string>
<key>CFBundleVersion</key>
<string>4</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2020 Julien Mulot</string>
<string>Copyright 2021 Julien Mulot</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
4 changes: 3 additions & 1 deletion SubnetCalc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
8D1107310486CEB800E47090 /* SubnetCalc-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SubnetCalc-Info.plist"; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* SubnetCalc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SubnetCalc.app; sourceTree = BUILT_PRODUCTS_DIR; };
945E62EF25658A9500CDC9C7 /* SubnetCalc.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = SubnetCalc.xctestplan; sourceTree = "<group>"; };
945E62F525658DBF00CDC9C7 /* SubnetCalcUITests-Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SubnetCalcUITests-Runner.app"; sourceTree = BUILT_PRODUCTS_DIR; };
945E62F525658DBF00CDC9C7 /* SubnetCalcUITests-Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; name = "SubnetCalcUITests-Runner.app"; path = SubnetCalcUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
945E62F925658DBF00CDC9C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9482A32625765B30008D2C56 /* SubnetCalcUITest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubnetCalcUITest.swift; sourceTree = "<group>"; };
949420B712D3C62A00E2F57D /* License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License.txt; sourceTree = "<group>"; };
Expand Down Expand Up @@ -401,6 +401,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_HARDENED_RUNTIME = YES;
GCC_DYNAMIC_NO_PIC = NO;
Expand Down Expand Up @@ -428,6 +429,7 @@
CODE_SIGN_ENTITLEMENTS = SubnetCalc.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = VNLK894MAE;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
Loading

0 comments on commit 5cc46aa

Please sign in to comment.